这可能是常见问题。我看到了这个问题的几个答案。
- 使用 jquery 加载
- 使用 iframe
我尝试了它们,但无法轻松加载。这是用于加载 google.com,但它不起作用。
<html>
<head>
<title>hhh</title>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#content").attr("src","http://www.google.lk/");
})
</script>
</head>
<body>
<iframe id="content" src="about:blank"></iframe>
</body>
</html>
但是当我尝试加载 w3schools.com 时,它会加载到 iframe
<html>
<head>
<title>hhh</title>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#content").attr("src","http://w3schools.com/");
})
</script>
</head>
<body>
<iframe id="content" src="about:blank"></iframe>
</body>
</html>
使用 jQuery 加载时,它也不起作用。
<html>
<head>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#content").load("src","http://www.google.com/");
})
</script>
</head>
<body>
<div id="content" src="about:blank"></div>
</body>
</html>
在萤火虫栏中用“ GET http://www.google.com 302 Found 291ms
”显示
一些身体帮助我摆脱这个。