【问题标题】:Global Variable in jQuery Mobile not working anymorejQuery Mobile 中的全局变量不再起作用
【发布时间】:2014-09-23 14:24:43
【问题描述】:

我使用 jQuery Mobile 框架将我的网站更改为移动网站。为了将变量保存并覆盖到另一个站点,我使用了一个框架并声明了像top.variable = "..."; 这样的变量。

这对我有用,但现在我使用 jQuery Mobile,它不会保留变量,它只会停止函数。

<form id="login">
    <input href="#" name="name"  id="name" type="text"/>
</form>

<a href="#" id="next" class="ui-disabled" data-role="button" onclick="next()">Send</a>
function next() {   
    top.username = document.getElementById("name").value;
    document.getElementById("nextSite").submit();
}

谁能告诉我为什么会这样?

【问题讨论】:

  • nextSite 在哪里????
  • 您好,'nextSite' 是我下一个 html 站点的 ID。
  • 不是 100% 确定,但你不需要 (var top = '';) 在你的函数顶部。看起来你不是在声明一个变量。

标签: javascript jquery jquery-mobile global


【解决方案1】:

你为什么不试试这个?

top.username=document.getElementById("iframeid").contentDocument.top.username;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    相关资源
    最近更新 更多