You do it like this:
var iframeHeaderCell = document.getElementById('wheretoputheiframe');
var dynamicURL = 'http://...' //your url
var iframeHeader = document.createElement('IFRAME');
iframeHeader.id = 'iframeHeader';
iframeHeader.src = dynamicURL ;
iframeHeader.width = ...;
iframeHeader.height = ...;
iframeHeader.scrolling = 'no';
iframeHeader.frameBorder = 0;
iframeHeader.align = 'center';
iframeHeader.valign='top'
iframeHeader.marginwidth = 0;
iframeHeader.marginheight = 0;
iframeHeader.hspace = 0;
iframeHeader.vspace = 0;
iframeHeaderCell.appendChild(iframeHeader);
Elementry, my dear Watson.
Isn't it more useful to just append the timestamp to the url in query string ?
ReplyDeleteNop. The problem is that if your page have an <iframe src=something> and then you change that src to something else, the browser (sometimes) remebers the first src in the history, and we wanted to avoid that.
ReplyDeleteThe (sometimes) is mostly related to what the original page was, what the new page is, and whether SSL is used or not. Also see for more details.
Oh, you were talking about the back button in the browser, i thought it was about cache :)
ReplyDeleteGreat Idea...Sherlock...Thanks a lot
ReplyDeleteReally kool trick, i'm looking for this.
ReplyDeletethx a lot xD.
Clever technique. Thanks for the tip, we were having the same issue w/ the iframe writing to browser history. Thanks!
ReplyDeleteThanks Nir, great solution.
ReplyDeleteI'm using iFrames to simulate an AJAX system since the pure AJAX system I was using often lagged and/or crashed. While this post didn't relate exactly to what I was looking for, it gave me the idea I needed. Thanks :)
ReplyDeleteExcellent info. Definitely fixed the issue we were having. Thanks!
ReplyDeleteit did work well for me where I wanted to avoid setting of browser history on all browsers except IE, any ideas or other workarounds?
ReplyDelete@anonymous, please elaborate the IE issue..
ReplyDeleteYou saved my day! I had some thought to solve this way. You just confirmed that it works. Thanks!
ReplyDeletewhat about an iframe that may contain other frames or iframes? If I don't have control over the iframes within the original iframe then am I out of luck?
ReplyDelete