javascript - 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上看到的:
我尝试通过其他浏览器(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>
结果:
解决方案
推荐阅读
- python - 如何从列表中提取数据框的名称并将其作为标题打印到输出?
- javascript - CSS半页固定半滚动不流畅
- android - FLUTTER - 有人可以帮我执行这个帖子按钮吗?
- android - 如何在不使用共享首选项的情况下仅显示一次任何活动?
- angular - 错误 TS1086:无法在环境上下文中声明访问器
- javascript - 如何根据按下的按钮切换 HTML5 输入“必需”功能
- php - Facebook Graph API - 尝试获取用户数据时出错
- javascript - 如何在其他任何事情之前从服务器加载对象 - vuejs - vuex
- php - 为什么会话破坏了移动浏览器中的每个页面加载?
- r - 如何用字典中的值替换数据框列中的每个单元格?