Javascript 将web链接加载到div或iframe
这可能是常见的问题。我看到了关于这件事的几个答案Javascript 将web链接加载到div或iframe,javascript,jquery,html,css,Javascript,Jquery,Html,Css,这可能是常见的问题。我看到了关于这件事的几个答案 使用jqueryload 使用iframe 我两个都试过了,无法轻松加载。 这是为了加载google.com,但它不起作用 <html> <head> <title>hhh</title> <script src="jquery.js"></script> <script type="text/javascript
<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>
啊
$(文档).ready(函数(){
$(“#内容”).attr(“src”http://www.google.lk/");
})
但当我尝试加载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>
啊
$(文档).ready(函数(){
$(“#内容”).attr(“src”http://w3schools.com/");
})
使用jqueryload时,它也不起作用
<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>
$(文档).ready(函数(){
$(“#内容”).load(“src”http://www.google.com/");
})
在firebug栏中,用“GET”来显示这一点http://www.google.com 302找到291ms
“
有人帮我解决了这个问题。使用jquery load在div中显示内容。div没有
src
影响iframe的src
告诉浏览器获取内容并在iframe中显示
load()
的正确语法为:
<div id="content"></div>
顺便说一句,google.com不喜欢从其他网站加载,因此最好使用其他示例。使用jquery load在div中显示内容。div没有src
影响iframe的src
告诉浏览器获取内容并在iframe中显示
load()
的正确语法为:
<div id="content"></div>
顺便说一句,google.com不喜欢从其他网站加载,所以你最好使用另一个例子。你想做什么?@Chanckjh:请原谅拼写错误,不是每个人都写英语,我想这是一个重复:@JFK是的,但iframe不是你正在使用的真正的英语。加载错误(为了记录)例如$(“#content”).load(');你想做什么?@Chanckjh:请原谅打字错误,不是每个人都写英语,我想这是这个的重复:@JFK是的,但iframe不是你正在使用的英语。加载错误(记录在案)例如$(“#内容”)。加载(');