safari ReferenceError:找不到变量changestyledisplayblock

时间:2011-12-07 16:19:33

标签: javascript html xhtml safari

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>The Goodies</title>
    <link rel="stylesheet" href="core.css" type="text/css"/>
    <meta name="generator" content="DocBook XSL Stylesheets V1.74.0"/>
    <script type="text/javascript"> function changestyledisplayblock(id){ var ps = document.getElementsByTagName('p'); for (var i=0; i &lt; ps.length; i++) { if (ps[i].id == id) { if ( ps[i].style.display == 'none' ) {ps[i].style.display = 'block';} else {ps[i].style.display = 'none';} } } } </script>
</head>
<body>
    <div class="sect1" title="The Goodies">
        <div class="sect2" title="Multimedia">
            <div class="titlepage">
                <div>
                    <div>
                        <h2 class="title">
                            <a id="multimedia">Multimedia</a>
                        </h2>
                    </div>
                </div>
            </div>
            <p class="bubble speech" id="bubble-speech-0 " style="display:none;">*0 : My first one !</p>
            <p class="bubble speech" id="bubble-speech-0 " style="display:none;">*0 : My second one !</p>
            <p>text <a class="marker" href="javascript:changestyledisplayblock('bubble-speech-0 ')">*0 </a>next</p>
        </div>
    </div>
</body>
</html>

这里是我的HTML,我有错误ReferenceError:找不到变量changestyledisplayblock,我没有看到任何错误,请帮忙!如果我将我的HTML扩展名更改为xhtml我再也看不到问题了???任何解释?

1 个答案:

答案 0 :(得分:1)

那'&lt;'应该是一个小于标志。或者粘贴代码时出错了吗?

另外,我建议不要在锚标记中调用javascript代码。