I created two simple html pages, one of which contains an iframe, and the second into this iframe of the first page. The first page is at http://quatorze.atspace.co.uk/Webdev/shared/ffbug1.html
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>:target bug in firefox</title> <style type=text/css> iframe:target { display: none; } ol { max-width: 480px; font-family: sans-serif; } li { margin: 8px; } span { color: red; } </style> </head> <body> <div id="div0"> <p><a href="#if">HIDE</a> <a href="#div0">SHOW</a></p> <iframe id="if" src="ffbug_files/ffbug3.html" width="400" height="200"></iframe> <ol>In Firefox click links on this page in following order: <li>Click "DIV 1". First div gets targeted and its background turns silver;</li> <li>Click "HIDE". Iframe gets targeted and its "display" property is set to "none";</li> <li>Click "SHOW". Iframe is no longer targeted and its "display" property is reset to "inline";</li> <li>Now click "DIV 2". Second div gets targeted and its background turns silver. First div is no longer targeted and its "background-color" must be reset to "skyblue" but <span>it remains silver</span>;</li> <li>Click "DIV 1". First div gets targeted, its background <span>was already silver</span>, second div is no longer targeted and its "background-color" is reset to "skyblue".</li> <li>Click "DIV 2". Second div gets targeted, its background turns silver, first div is no longer targeted, its "background-color" is reset to "skyblue".</li> <li>Click "HIDE". Iframe gets targeted and its "display" property is set to "none";</li> <li>Click "SHOW". Iframe is no longer targeted and its "display" property is reset to "inline";</li> <li>Now click "DIV 1". First div gets targeted, its background turns silver. Second div is no longer targeted and its "background-color" must be reset to "skyblue", but <span>it remains silver</span>. </ol> </div> </body> </html>
The second page loaded in the iframe is at http://quatorze.atspace.co.uk/Webdev/shared/ffbug_files/ffbug3.html
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>:target bug in firefox</title> <style type=text/css> div { width: 140px; height: 140px; border: 2px solid; margin: 6px; padding: 10px; background-color: skyblue; float: left; } div:target { background-color: silver; } </style> </head> <body> <div id="div1"><a href="#div1">DIV 1</a></div> <div id="div2"><a href="#div2">DIV 2</a></div> </body> </html>
As you can see, on the first page there are two links named "SHOW" and "HIDE".
"SHOW" refers to the containing div, and "HIDE" refers to the iframe.
The iframe property "display" is set to "none" when it becomes the target.
The second page loaded in the iframe contains two divs. Each div has a link inside it that references that div.
The CSS rule set on each div forces it to change its background color when it targets from skyblue to silver.
In Firefox, try clicking on the links on the first page in the following order:
Press "DIV 1". The first div becomes the target, and its background silver turns;
Click HIDE. Iframe gets the target value and its display property is set to none;
Click on SHOW. Iframe is no longer targeted, and its "display" property reset to "inline";
Now press "DIV 2". The second div takes aim, and its background turns Silver. The first div is no longer targeted, and its "background color" should be reset to "skyblue" (which actually happens in Chrome), but it remains silver.
source share