通过jquery加载网址不起作用?

时间:2015-03-11 05:28:16

标签: jquery html

<!doctype html>
<html lang="en">
<head>
<title>test page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<div id="My-page" style="width:900px; height:900px; position: absolute;overflow-x:hidden !important;-webkit-overflow-scrolling:touch !important;" class="iframely-widget-container">
<script>$("#My-page").load("http://www.flipbeets.com/display-embed-code/ZG9sY2VnYWJiYW5h/OTAwcHg=/OTAwcHg=/MQ==/MQ==/MQ==");</script>
</div>
</body>
</html>

我试图通过jquery将flipbeets.com网址加载到div但是它无法正常工作

3 个答案:

答案 0 :(得分:1)

试试这个......

<div id="My-page" style="width:900px; height:900px; position: absolute;overflow-x:hidden !important;-webkit-overflow-scrolling:touch !important;" class="iframely-widget-container">
</div>
<script>
$( "#My-page" ).html('<object data=http://www.flipbeets.com/display-embed-code/ZG9sY2VnYWJiYW5h/OTAwcHg=/OTAwcHg=/MQ==/MQ==/MQ=="/>');       

</script>

答案 1 :(得分:0)

您可以使用iframe代替div来加载外部网站内容。

 <iframe id="My-page"></div>

<强>的jQuery

$("#My-page").attr("src","http://www.flipbeets.com/display-embed-code/ZG9sY2VnYWJiYW5h/OTAwcHg=/OTAwcHg=/MQ==/MQ==/MQ==");

<强> Demo

答案 2 :(得分:0)

你可以像这样使用iframe

<html lang="en">
<head>
<title>test page</title>

</head>
<body>

 <iframe style="width:900px; height:900px; position: absolute;overflow-x:hidden !important;-webkit-overflow-scrolling:touch !important;"  src="http://www.flipbeets.com/display-embed-code/ZG9sY2VnYWJiYW5h/OTAwcHg=/OTAwcHg=/MQ==/MQ==/MQ=="></iframe>


</div>
</body>
</html>