1

Is there a way for me to detect if the style attribute of a class changes, for example, a change in display or visibility?

The situation I have is that I have a Podio webform embedded on my site via iframe and that has a hidden thank you message in .webforms__success-message > p and I want to scroll to the success message when it appears on the page.

11
  • 3
    I'm not 100% sure you can even get to the content of a remote URL in an iframe via jquery, I could be wrong though but the security implications would be horrendous! Commented Dec 30, 2016 at 17:49
  • I am able to trigger a DOM event using the class so I would guess yes Commented Dec 30, 2016 at 17:50
  • stackoverflow.com/questions/3083112/… Commented Dec 30, 2016 at 17:51
  • @SandraWillford I flagged this as duplicate, take a look at the previous discussion. Commented Dec 30, 2016 at 17:51
  • 1
    @Dale is on point - you can't access an iFrame's content via javascript. Browsers prevent this for security purposes. Commented Dec 30, 2016 at 17:51

1 Answer 1

0

I would recommend VueJS instead of jQuery. It's faster because it uses a virtual dom and it doesn't have to traverse the dom in order to detect changes. You simply create an action and then emit that action as an event. Then you can call whichever jQuery functions you would like.

<div id="app">
   <iframe v-show="isShowing" src="http://www.weather.gov/" 
        frameborder="0"
        ></iframe>
  <button @click="isShowing ^= true">Click Me</button>
</div>

CSS

iframe {
  display:block;
  margin-top: 20px;
  margin-left: 200px;
  width:850px;
  height:300px;
}

JS

var vue = new Vue({
  el:"#app",
  data: {
    isShowing:false,
  }
})

check out this Codepen

Sign up to request clarification or add additional context in comments.

1 Comment

Not in an iFrame...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.