[英]Index.html Script Tag Values Replaced On Run
I'm having an issue with CORS and web page:我遇到了 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>
Turns to:转为:
<!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>
The error is:错误是:
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.
Why is the source changing before read by Chrome?为什么在 Chrome 读取之前源会发生变化?
Write the script in another page & link it in the bottom head or body tag.在另一个页面中编写脚本并将其链接到底部的头部或正文标记中。 As like:就像:
<script src="Right the link page" type="text/javascript">
function...
</script>
</body>
Or:或者:
<script type="text/javascript" src="Right the link page">
function...
</script>
</head>
Write the script language in the head tag and try or in the bottom body tag.将脚本语言写在head标签和 try 或底部 body 标签中。 As like:就像:
<script type="text/javascript">function...
</script>`
</body>
Or或者
<script type="text/javascript"></script>`
</head>
Than isn't than please remove your browser history, & close all tab than right the URL in the browser tab & run.请删除您的浏览器历史记录,并关闭所有选项卡,然后在浏览器选项卡中关闭 URL 并运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.