[英]GWT ScriptInjector VS adding script tag to index.html page
[英]Index.html Script Tag Values Replaced On Run
我遇到了 CORS 和 web 页面的问题:
<!DOCTYPE html>
<html lang="en">
<head>
<script
type="text/javascript" crossorigin="anonymous">$(function () { $.get("assets/head.html", function (data) { $("head").prepend(data); }); });</script>
</head>
<body class="container">
</body>
</html>
转为:
<!DOCTYPE html>
<html lang="en">
<head>
<script
type="text/javascript" crossorigin="anonymous">$(function () { $.get("https://s3-example.amazonaws.com/aws-codestar-example/public/assets/head.html", function (data) { $("head").prepend(data); }); });</script>
</head>
<body class="container">
</body>
</html>
错误是:
Access to XMLHttpRequest at 'https://s3-example.amazonaws.com/aws-codestar-example/public/assets/head.html' from origin 'http://example2.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
为什么在 Chrome 读取之前源会发生变化?
在另一个页面中编写脚本并将其链接到底部的头部或正文标记中。 就像:
<script src="Right the link page" type="text/javascript">
function...
</script>
</body>
或者:
<script type="text/javascript" src="Right the link page">
function...
</script>
</head>
将脚本语言写在head标签和 try 或底部 body 标签中。 就像:
<script type="text/javascript">function...
</script>`
</body>
或者
<script type="text/javascript"></script>`
</head>
请删除您的浏览器历史记录,并关闭所有选项卡,然后在浏览器选项卡中关闭 URL 并运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.