Is there any way for a iframe nested in a div on my page not to reload when I change pages in the nav? Because when I change pages it will load the code of the page and the iframe on the previous page will be reloaded. Is there any way that I can select it and make that it won’t reload when I change pages?
Share
My initial reaction is: “Why the hell would you want to do that, it sounds awful?”
The only way for this to work is to change the page content dynamically, with the exception of the iframe, rather than loading a new page.
But to answer your question, yes you can do it.
If you have all the page content except the iframe inside a div, lets call it
#pageand the iframe is at the same level in the DOM, or higher, relative to #page, you could use something like jQuery’s load() function to load new content for everything inside the #page div.However, if SEO or Accessibility matter to you at all, you shouldn’t do this.
A users browser will cache a lot fo the content in the iframe anyway, so it shouldn’t be too demanding to reload it.