After I update an iframe’s src attribute using : document.getElementById('iframe1').src = newsrc and then attempt to read it: alert(document.getElementById('iframe1').src); The src I get is the old source and not the new one that was set. Why is this and how can I get the real current src value?
After I update an iframe’s src attribute using : document.getElementById(‘iframe1’).src = newsrc and then
Share
If the.srcis pointing to a different domain, you can’t get it. It’s a security feature. I guess IE’s way of implementing that security feature is to return the old value forsrcCorrection: After reading Pekka’s comments, I went ahead and tested it. You can try it too at http://jsfiddle.net/pMtZC/ (caution: alerts).
On all browsers I tested it in (Chromium, Firefox 4, IE 8), the changed
srcproperty was returned just fine. If you set it, it will return the value you set to it. It will not, however, change if the user navigates within the iframe (obviously). What version of IE are you using?