javascript change iframe src and reload
2023-09-21

"Signpost" puzzle from Tatham's collection. If the iframe was not on a different domain, you could do something like this: But since the iframe is on a different domain, you will be denied access to the iframe's contentDocument property by the same-origin policy. Share How to append HTML code to a div using JavaScript ? I honestly only wanted to comment because your commenting system is gorgeous. email is in use. The issue is that a hashchange doesn't force a reload of the iframe, Force iframe to (re)load document when only src hash changes, http://paulrad.com/stackoverflow/iframe-hash-detection.html. Connect and share knowledge within a single location that is structured and easy to search. In contrast, the. Setting iframe src and calling it's location.reload, but that reloads the originally loaded url; Setting the iframe location.href/hash and calling reload, same issue; Blanking the src attribute and then setting the new url - no effect; The only solution I can find is to set the src to a blank screen, then onload set it to the new url: Can you still use Commanders Strike if the only attack available to forego is an attack against an ally? javascript - Reload an iframe with jQuery - Stack Overflow Maybe add a dynamic GET parameter f.e. So basically i need a way(function?) By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. absolute it's work, but stuck with same domain origin policy ==a. I have a JS plug in and it will have a variable called newURL ready and this newURL is another aspx page. I've just tested the same approach but without setTimeout - and it worked for me. The trouble is, the new url doesn't actually point to a new page, it only uses a changed hash. Do you need your, CodeProject, Note: As mentioned by @user85461, this approach doesn't work if the iframe src URL has a hash in it (e.g. The reason I couldn't get any of the other methods to work is because I was testing them in Chrome, and Chrome won't allow you to access an iframe's content (Explanation: Is it likely that future releases of Chrome support contentWindow/contentDocument when iFrame loads a local html file from local html file?) Now if only I could figure out how to keep the iframe from scrolling the parent page each time there's animation inside iframe EDIT: rev2023.4.21.43403. Embedded hyperlinks in a thesis or research paper, Word order in a sentence with two clauses, How to create a virtual ISO file from /dev/sr0, Generate points along line, specifying the origin of point generation in QGIS. This causes the iframe to scroll back to the top. Thanks for contributing an answer to Stack Overflow! Just reciprocating Alex's answer but with jQuery: this is useful especially when