【问题标题】:JQuery mobile dialog error SecurityError: The operation is insecureJQuery 移动对话框报错 SecurityError: The operation is insecure
【发布时间】:2015-08-10 08:11:37
【问题描述】:

我使用 HTML 和 JQuery mobile 进行 phonegap,但是当我使用此代码测试它时,它显示错误 SecurityError: The operation is insecure。 F或 changepage 功能运行良好,为什么会发生这种情况?

$.mobile.changePage( "#confirm", { 
        role: "dialog"
})

这是我在 index.html 文件中的 Dialog HTML

<div data-role="page" id="confirm">
      <div data-role="header" id="header">
        <div class="header">
            <div class="header-logo"></div>
        </div>
        <div class="header-bottom"></div>           
      </div>

      <div data-role="content" class="ui-content" id="logedin-view">
            <div class="border-logedin">
                <center><h3>Title Loged in Main</h3></center>
            </div>              
            <form id="codesend">
                <input type="text" id="code" class="input" placeholder="Code" required/>
            </form>
            <center>
                <button type="submit" form="codesend" id="code-send" class="input btn-submit" value="submit" data-role="none">Submit</button>
            </center>
            <a href="#index" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b ui-icon-back ui-btn-icon-left" data-rel="back">Go Back</a>
      </div>

      <div class="footer" data-role="footer">
      </div>
    </div> 

【问题讨论】:

    标签: javascript jquery html cordova jquery-mobile


    【解决方案1】:

    在这种情况下,问题出在这一行:

    window.history.replaceState( state, state.title || document.title, href );
    

    (在版本 1.4.5 第 2954 行)

    我不确定它的作用,但是在注释掉它之后,我的代码就可以工作了。

    【讨论】:

      【解决方案2】:

      其中大部分问题都与同源政策有关。从不同的域加载 js 文件或 css 规则可能会导致问题。

      当您在本地测试代码时,您可能会从 cdn// 或其他远程服务器加载其他文件,这会导致 jQuery 脚本中的跨域安全错误。

      【讨论】:

      • 在我的情况下“可能”只有一个显示错误的函数,其他的很好,这让我感到困惑
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多