js內部引用及外部引用無效


1.正常情況及效果

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>index</title>
        <script src="../js/jquery-3.4.1.js"></script>
        <script type="text/javascript">
            window.onload = function(){
                console.log("test")
            }
        </script>
    </head>
    <body>
        <h1>index</h1>
    </body>
</html>

Ps:正常情況下頁面訪問及js功能正常運作

 

2.非正常情況下及效果

2.1js單標簽后還有內部js的使用或外部js的引用

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>index</title>
        <script src="../js/jquery-3.4.1.js"/>
        <script type="text/javascript">
            window.onload = function(){
                console.log("test")
            }
        </script>
    </head>
    <body>
        <h1>index</h1>
    </body>
</html>

 

 

2.2js的單標簽前還有內部js使用或外部js的引用

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>index</title>
        <script type="text/javascript">
            window.onload = function(){
                console.log("test")
            }
        </script>
        <script src="../js/jquery-3.4.1.js"/>
        
    </head>
    <body>
        <h1>index</h1>
    </body>
</html>

 

Ps:如果頁面中使用了內部或外部js過程中,js使用了單標簽的形式,頁面會出錯,此標簽后的代碼會變成灰色,無法正常運行。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM