IFrame - - - By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Not the answer you're looking for? Tested with IE7/8, Firefox and Chrome. Connect and share knowledge within a single location that is structured and easy to search. There is a lot of commenting with the Gist: Here my solution (based on this stackoverflow answer): You can test this here: http://paulrad.com/stackoverflow/iframe-hash-detection.html. Now he has a webpage, which contains an IFrame and a Button. The custom function that we will be using is really simple, it only has 3 lines of code! Logically you'd want to be able to easily and quickly refresh any given frame. Hope this helps someone. If you can target newer browsers, consider using HTML5's Cross-document messaging. jQuery has the load method, which is useable like so (assuming borderlessFrame is the id of the by on load in webpage and once user interacted on screen the iframe will change to src="https://www.youtube.com/embed/uI7fnrNhKSI"its something like innerHTML.replace(new RegExp("loadYoutubeEmbed"),"www.youtube.com/embed")any help available . - Sergey Orshanskiy Oct 16, 2021 at 18:33 Add a comment 24 Answers Sorted by: 289 change src of iframe and then reload the iframe. The only solution I can find is to set the src to a blank screen, then onload set it to the new url: This works, yet it seems inefficient because there's an extra step. Content Discovery initiative April 13 update: Related questions using a Review our technical responses for the 2023 Developer Survey, Can't refresh reCaptcha on JQuery Ajax return, JavaScript: When printing a full web page, IE doesn't seem to print the contents of iFrames on the page, Jquery setting .attr to an iframe scrolling=yes, CORS error when trying to reload an embedded iframe, Refreshing an iframe after ajax POST submit, Oracle ApEx collection info not appearing within PL/SQL region, jQuery show div with child iframe (wysiwyg text editor). If you are cross-domain, simply setting the src back to the same url will not always trigger a reload, even if the location hash changes. I remember researching what you're talking about about a year ago. iframes Code Snippets jQuery Code Snippets Force an Iframe to Reload Chris Coyier on Aug 17, 2011 (Updated on Jul 20, 2019 ) You can touch the src of it: $ ('iframe').attr ('src', $ ('iframe').attr ('src')); Psst! Problems with the .click javascript when switching pages. Asking for help, clarification, or responding to other answers. As you can access the window element of the iframe with contentWindow, you have to do this: // Get the iframe const iframe = document.getElementById('myIframe'); // Reload the iframe iframe.contentWindow.location.reload(); Test:. How are we going to make this possible? This means that the iframe does not actually load the src url again because hash changes don't require it to. Whats the best way to reload / refresh an iframe? There was no 'contentWindow' property. How do I check whether a checkbox is checked in jQuery? By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. It's not the hash change I need to detect, I'm actually causing the hash change through javascript and would already know when it occurs. Hey Magnor, yes!You would need to extract the sfds654fsgfg6sfg54gfhghdf6 parameter first. Thanks once again :). How about saving the world? Easy peasy lemon squeezy! Setting the iframe location.href/hash and calling reload, same issue. That may have had something to do with why I couldn't get any of the other solutions to refresh my particular frame. The idea behind changing the iframe source is to switch the web page in the display of iframe. Im currently using this version of the script, but its breaking the rest of the scripts on my page. It won't be seen & if you are aware of the parameter being safe then it should be fine. How do I stop the Flickering on Mode 13h? email is in use. 565), Improving the copy in the close modal and post notices - 2023 edition, New blog post from our CEO Prashanth: Community is the future of AI. Get the URL of the document that is shown in an iframe: HTML reference: HTML