为什么这些空脚本标签会阻止我的页面工作?

Dan*_*007 5 html javascript parsing backbone.js parse-platform

在此代码的基础上有以下 3 个脚本标记。我不希望它们出现在我的 html 文档中,但如果我尝试删除它们,它们会阻止我的 <script type="text/template" id="login-template">表单正常工作。基本上它似乎隐藏了输入字段。

为什么是这样?

我什至删除了 ` 中的 JS 实际代码来尝试解决这个问题。

   <script type="text/template" id="manage-todos-template"></script>
   <script type="text/template" id="item-template"></script>
   <script type="text/template" id="stats-template"></script>
Run Code Online (Sandbox Code Playgroud)

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <meta name="description" content="fresh Gray Bootstrap 3.0 Responsive Theme "/>
    <meta name="keywords" content="Template, Theme, web, html5, css3, Bootstrap,Bootstrap 3.0 Responsive Login" />
    <meta name="author" content="Adsays"/>
    <title>Parse JavaScript Todo App</title>
    <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
    <script src="scripts/underscore-1.1.6.js"></script>
    <script src="http://www.parsecdn.com/js/parse-1.2.13.min.js"></script>
    <script src="scripts/todos.js"></script>

    <link rel="shortcut icon" href="favicon.png"> 

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/login-theme-1.css" rel="stylesheet">
    <!-- 

    -->


    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
      <link href="css/animate-custom.css" rel="stylesheet"> 
      <![endif]-->



      <script src="js/custom.js" type="text/javascript" ></script>

  </head>

  <body>



    <!-- Login, sign up and lost password box-->
    <div class="container" id="login-block">
        <div class="row">
            <div class="col-sm-6 col-md-4 col-sm-offset-3 col-md-offset-4">
                <div class="page-icon-shadow animated bounceInDown" > </div>
                <div class="login-box clearfix animated flipInY">
                    <div class="login-logo">
                        <a href="#"><img src="img/login-logo.png" alt="Company Logo" /></a>
                    </div> 
                    <hr />
                    <div class="login-form content">
                        <!-- Error messages if details not entered-->
                        <div class="alert alert-danger hide">
                            <button type="button" class="close" data-dismiss="alert"> &times;</button>
                            <h4>Error!</h4>
                            Your Error Message goes here
                        </div></div> </div> </div> </div> </div>
                        <!-- End Error box -->

                        <!-- This is the Parse generated code that generates from the js file to populate the page and manage Parse user authentication -->
                        <script type="text/template" id="login-template">
                        <header id="header"></header>
                        <div class="login">
                        <form class="login-form">
                        <div class="error" style="display:none"></div>
                        <input type="text" id="login-username" placeholder="User name" class="input-field" required/> 
                        <input type="password" id="login-password" placeholder="Password" class="input-field" required/> 
                        <button type="submit" class="btn btn-login">Login</button> 

                        <!--//Parse code ends here-->

                        <!--//Links to sign up and lost password pages-->

                        <div class="login-links"> 
                        <a href="forgot-password.html">
                        Forgot password?
                        </a>
                        <a href="sign-up.html">
                        Dont have an account? Click here to Sign Up
                        </a>
                        </div>

                        <!--//FB authentication button that fires the fb page to log user in --> 
                        <div class="social-login row">
                        <div class="fb-login col-lg-6 col-md-12 animated flipInX">
                        <a href="fb.html" class="btn btn-facebook btn-block">Connect with <strong>Facebook</strong></a>
                        </div>
                        </div>
                        </div>
                        </form>
                    </script>   <!--//Script must wrap around all the above code to display it correctly on screen -->          


    <!--XXXXX -->                   


    <script type="text/template" id="manage-todos-template"></script>
                    <script type="text/template" id="item-template"></script>
                        <script type="text/template" id="stats-template"></script>          


                </body>

                </html>
Run Code Online (Sandbox Code Playgroud)

anu*_*upr 2

您尝试删除的这些标签正在被模板引擎使用,这就是删除它会导致您的页面无法正常工作的原因。

脚本中可能没有内容,但它可能在其中添加/操作内容。当您在这些标签仍然完好无损的情况下运行页面时,您需要检查是否有任何内容被添加到这些标签中。