jQuery Mobile位于沙盒iframe中
我想在一个iframe中运行jquery移动站点,iframe是沙盒,但带有允许脚本。但它什么也看不出来jQuery Mobile位于沙盒iframe中,jquery,mobile,iframe,sandbox,Jquery,Mobile,Iframe,Sandbox,我想在一个iframe中运行jquery移动站点,iframe是沙盒,但带有允许脚本。但它什么也看不出来 <!Doctype html> <html> <head> <title>#1 JS Scope</title> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<!Doctype html>
<html>
<head>
<title>#1 JS Scope</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<!-- Libs -->
<script src="../../lib/jquery-1.8.2/jquery-1.8.2.js"></script>
<script src="../../lib/jquery-mobile-1.2.0/jquery.mobile-1.2.0.js"></script>
<link href="../../lib/jquery-mobile-1.2.0/jquery.mobile.structure-1.2.0.css" rel="stylesheet">
<link href="../../lib/jquery-mobile-1.2.0/jquery.mobile-1.2.0.css" rel="stylesheet">
</head>
<body>
<!-- Page -->
<div data-role="page" id="home">
<!-- Header -->
<div data-role="header" data-theme="a">
<h1>Top</h1>
</div>
<!-- Content -->
<div data-role="content" data-theme="c" id="frame">
<iframe src="http://jquerymobile.com/demos/1.2.0/" sandbox="allow-scripts" width="926" height="974"></iframe>
</div>
</div>
</body>
</html>
#1 JS范围
顶部
它是沙盒,因为我想阻止完成的jquery移动应用程序访问包装页面的DOM。因此,只允许脚本被设置为允许运行jquery mobile的javascript
但是iframe只显示白色,我真的不知道会出什么问题。因为jquery不需要访问父DOM来显示某些内容。jquery Mobile尝试操纵浏览器历史记录(history.replaceState),这在沙盒中是不允许的
init: function() {
$win.bind( "hashchange", self.onHashChange );
// Handle popstate events the occur through history changes
$win.bind( "popstate", self.onPopState );
// if there's no hash, we need to replacestate for returning to home
if ( location.hash === "" ) {
history.replaceState( self.state(), document.title, $.mobile.path.getLocation() );
}
}