为什么这个内联javascript不能在Firefox中运行?我怎样才能让它在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>
Run Code Online (Sandbox Code Playgroud)
在Safari中,这应该是它应该出现的.在Firefox中它暂时出现间隙(好像浏览器处于怪癖模式),然后页面上的所有内容都消失,取而代之的是"块".起初我认为这意味着Firefox阻止它,但它说"内联",而不是如果我设置的样式显示.
编辑:我的问题的Javascript部分现在解决了.但是标题背景的显示方式仍然存在差异:它在Safari中向下延伸到div边界,但在Firefox中则不然.有没有办法让它在Firefox中这样做?