V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
guyeuro
V2EX  ›  问与答

firebug 的 javascript 调试器为何不显示当前页面?

  •  
  •   guyeuro · Aug 18, 2017 · 1271 views
    This topic created in 3174 days ago, the information mentioned may be changed or developed.

    我打开一个页面

    javascript 是内嵌在这个页面的

    源码如下

    但是 firebug 的 avascript 调试器没有当前页面

    而 web 控制台错误信息说 func() not defined

    怎么回事

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    
    <html>
      <head>
        <title>Title</title>
    
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js">
            function func(){
                $("#show").html("hha");
                alert("haha");
            }
        </script>
      </head>
    
      <body>
      <p onclick="func()"> 点击我</p>
      <p id="show"></p>
      </body>
    </html>
    
    1 replies    2017-08-19 08:49:38 +08:00
    autoxbc
        1
    autoxbc  
       Aug 19, 2017 via iPhone
    你的 script 标签,既用了内联语句,又用了外链语句,此时浏览器会忽略内联部分,所以 func() 未定义。拆成两个标签。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4003 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 10:26 · PVG 18:26 · LAX 03:26 · JFK 06:26
    ♥ Do have faith in what you're doing.