我正在尝试打开一个带有跳转锚点的div。打开部分已经起作用,但没有跳转到指定的锚点。
这是我的脚本:
<script type="text/javascript">
function spoil(id){
if (document.getElementById) {
var divid = document.getElementById(id);
divid.style.display = (divid.style.display = 'block');
window.location = '#' + id;
}
}
</script>
<a href="http://example.com" onclick="spoil('thanks');" title="hello">
<img src="images/gfx.png" alt="world" width="300" height="300"/>
</a>
有什么想法是错的吗? 谢谢。