首页 > 解决方案 > JQuery 适用于 OBS 但不适用于浏览器

问题描述

我在使用 JQuery 时遇到问题。如果我在 HTML 页面中使用它,只有通过 OBS(流媒体平台,是的)查看页面,才能使其完美运行。如果我通过浏览器打开同一页面,它将无法正常工作。

示例:这是test.html. jquery-3.5.1.min.js它与和位于同一文件夹中test2.html

<html>
    
<head>

    <script type="text/javascript" src="jquery-3.5.1.min.js"></script>
    
    <script>
        $(document).ready(function(){
            $('#asd').load("test2.html");
        });
    </script>
    
</head>

<body bgcolor="white">

    <div id="asd">
    </div>

</body>
</html>

这是test2.html

<html>

<head>
</head>

<body>
    
    asdhasdhashdashdhasdhasdhasdhasdhashdashd asdh asdha sdh asdh asdh asdh asdh asdh asdhds ahsd sdha sd
    
</body>

</html>

例如,这是我在 Firefox 上看到的:

火狐

这是我在OBS上看到的:

OBS

我尝试通过其他浏览器(Edge、Opera)打开它,也是一样。

我试图通过 JQuery 做一个“Hello World”,它确实有效,所以我真的不确定此时缺少什么:

<html>

<head>

    <title>jQuery Hello World</title>

    <script type="text/javascript" src="jquery-3.5.1.min.js"></script>

</head>

<body>

    <script type="text/javascript">

    $(document).ready(function(){
        $("#msgid").html("This is Hello World by JQuery");
    });

</script>

This is Hello World by HTML

<div id="msgid">
</div>

</body>
</html>

结果:

火狐 2

标签: javascripthtmljqueryobs

解决方案


推荐阅读