【发布时间】:2013-01-08 20:24:40
【问题描述】:
这可能是常见问题。我看到了几个关于这个问题的答案。
- 使用 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”显示这个
一些身体帮助我摆脱这个。
【问题讨论】:
-
你想做什么?
-
@Chanckjh : 请原谅错别字,不是每个人的英语都写得很好
-
我猜这是这个的副本:stackoverflow.com/questions/8524449/…
-
@JFK 是的,但 iframe 不是真的英文
-
您使用 .load 错误(作为记录)例如。 $('#content').load('google.com/');
标签: javascript jquery html css