jquery mobile报错:Uncaught SecurityError: Failed to execute 'replaceState' on 'History':
用jquery.mobile.js库的时候,页面总是显示不出来,并且报错Uncaught SecurityError: Failed to execute 'replaceState' on 'History',解决方法如下:
在加载jquery.mobile.js之前,添加下面代码,就可以了。
<script> $(document).bind('mobileinit',function(){ $.mobile.pushStateEnabled = false; }); </script>
整体如下所示:
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <link rel="stylesheet" href="./jquery.mobile-1.2.0.css"/> 5 <script type="text/javascript" src='./jquery-1.7.1.min.js'></script> 6 <script> 7 $(document).bind('mobileinit',function(){ 8 $.mobile.pushStateEnabled = false; 9 }); 10 </script> 11 <script type="text/javascript" src='./jquery.mobile-1.2.0.js'></script> 12 <script> 13 14 15 $(document).on( "click", ".show-page-loading-msg", function() { 16 var $this = $( this ), 17 theme = $this.jqmData( "theme" ) || $.mobile.loader.prototype.options.theme, 18 msgText = $this.jqmData( "msgtext" ) || $.mobile.loader.prototype.options.text, 19 textVisible = $this.jqmData( "textvisible" ) || $.mobile.loader.prototype.options.textVisible, 20 textonly = !!$this.jqmData( "textonly" ); 21 html = $this.jqmData( "html" ) || ""; 22 $.mobile.loading( 'show', { 23 text: msgText, 24 textVisible: textVisible, 25 theme: theme, 26 textonly: textonly, 27 html: html 28 }); 29 }) 30 .on( "click", ".hide-page-loading-msg", function() { 31 $.mobile.loading( "hide" ); 32 }); 33 34 35 36 </script> 37 <title></title> 38 </head> 39 <body> 40 ...... 41 <body>