Jump to content

On iframe src change


retro-starr
 Share

Recommended Posts

Below I made a function that I feel should've updated the input field "url_input" with the value of the new src. This does not work though, so my question is what am I doing wrong?

 function iframe_address() {  $('#content["src"]').change(function() {    $('#url_input').attr('value', change());  }); };

#content being the iframesrc is the attribute I want to watch#input_input being the input fieldvalue being the attribute I want to update

Edited by retro-starr
Link to comment
Share on other sites

Just found out that JS/JQuery change() only works for input, select, and text areas not iframe; so I figure I'd have to do load() instead.This seems like it'd work, but I need someone more versed in JQuery to aid me on this.

 $('#content').load(function() {  var x = $('#content[src]');  $('#url_input').attr('value', x); });

Edited by retro-starr
Link to comment
Share on other sites

I got it! Only problem is that it's not aware of links from inside the iframe, so it doesn't update the src, but instead the contents of the iframe.I was close:

 $('#content').load(function() {  var x = $('#content').attr('src');  $('#url_input').attr('value', x); });

Edited by retro-starr
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...