Why does this embedded javascript not work in Firefox? And how can I make it work correctly in Firefox?
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <style> h2 {display:inline; padding:0px 7px 0px;} h2 a {text-decoration:none} h2 a:link {color:#FFFFFF;} h2#s0 {background-color:black;} </style> </head> <body> <h2 id="s0"><a href="javascript:document.getElementById('d0').style.display='block';"> Click me!</a></h2> <div id="d0" style="width:98%;border: 5px solid #000000;padding:3px; display:none;"> When you click the heading, this text should appear with a black outline, with no gap between that and the heading background.</div> </body> </html>
In Safari, it looks as it should. In Firefox, it appears for a moment with a space (like a browser in quirks mode), then everything on the page disappears, is replaced by the word "block". At first, I thought it meant that Firefox was blocking it, but instead it says "inline" if that is what I asked to display the style.
EDIT: Now the Javascript part of my problem is resolved. But there is still a difference in how the background title looks: it extends to the Div border in Safari, but not in Firefox. Is there a way to do this in Firefox?
javascript html css firefox
Aidan stanger
source share