Solution to Iframe display bug when Firefox returns_Experience exchange

PHP中文网
Release: 2016-05-16 12:06:00
Original
1948 people have browsed it

solution to the iframe display bug when firefox returns_experience exchange

<script type="text/javascript">//<![cdata[ 
if(getcookie('firefoxiframe')){ 
document.write('<p id="addad"><a href="cookie.html">点击这里删除这个iframe</a></p>'); 
document.write('<iframe height="120" width="300" marginheight="0" marginwidth="0" 
frameborder="0" src="nadpre.swf"></iframe>'); 
}else{ 
document.write('<p id="addad"><a href="cookie.html">点击这里增加一个iframe</a></p>'); 
} 
//]]></script>
Copy after login

open the bug demo. since the cookie does not exist, the three flashes displayed are all implemented through iframe
click "click here to add an iframe ad" and jump to a new page to write a cookie named firefoxiframe
click "return" or the browser's return button to return to the bug demo page. it was found that the flash in the iframe was misplaced, that is, the flash linked to the iframe at position 2 was not loaded. the flash at position 3 was displayed, and the flash at position 3 was displayed at position 4, but the flash at position 4 still existed.
close the tab (not close the entire browser, if the entire browser is closed, the cookie will also be invalid) or open a new tab and reload the page, 4 iframes will display 4 flashes normally
at this time, if click "click here to delete this iframe ad" and jump to a new page to delete the cookie. when you return, you will find that the flash in the iframe is misplaced.
if you write a cookie or delete a cookie, you will not go back through the browser and access it directly through the url. , then there will be no misalignment
simple analysis and solution
it seems that when firefox returns, javascript is re-executed, but the iframe is not reloaded according to the src attribute, but the iframe and src are given similar numbers. the pairing, and due to the execution of javascript when returning, there is one more (or one less) iframe, which causes the subsequent pairing to be misaligned.

the above is just speculation, but this is indeed a bug in firefox (2.0.0.3). javascript is re-executed when ie returns, and the iframe is reloaded based on src. javascript is not re-executed when opera returns. , the page has not changed.

the solution is to add a hidden iframe to the text to occupy the space. modify the above code as follows:

document.write('<p id="addAd"><a href="cookie.html">点击这里增加一个iframe</a></p>'); 
//把上面的代码修改成为 
document.write('<iframe src="#" style="display:none;"></iframe>'); 
document.write('<p id="addAd"><a href="cookie.html">点击这里增加一个iframe</a></p>');
Copy after login

the above is what firefox returns solution to iframe display bug_experience exchange content. for more related content, please pay attention to the php chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template