【问题标题】:url not opening in iframe网址未在 iframe 中打开
【发布时间】:2012-06-08 02:48:18
【问题描述】:

每当调用 createRemoteSampleWindow() 时,我都会调用以下 javascript 函数来打开/创建 iframe。问题是我在标题中的 DB 之后编写的菜单,onChange 在新窗口中打开链接,而不是在同一个 iframe 本身中打开。

function changeSpecies(selector){
var selected = document.getElementsByName(selector)[0].value;
var new_url = window.location.toString().replace(selected);
window.location.href = new_url;
}

function createRemoteSampleWindow() { // create a iframe window
var sampleWnd = $.window({
    url: "http://www.google.com",       
    title: 'DB <select id="click" OnChange="window.open(this.options[this.selectedIndex].value')" name="selector" target="sampleWnd"> <option value="http://www.goal.com" selected="">human</option> <option value="http://www.mirror.co.uk">mouse</option> <option value="http://www.espnstar.com">rat</option> </select>',
});

我提到了 target="sampleWnd",但这似乎不起作用。

请告诉我哪里出错了。

【问题讨论】:

    标签: javascript jquery jquery-ui iframe


    【解决方案1】:

    你有一个 ' 后值,它不应该是。

    【讨论】:

    • 我忘记在此处为引号添加反斜杠。因此,以下是新更新的代码标题:"DB ",但这不起作用。替换“标题后开头和结尾处的双inv逗号:用' - 至少在对话框的菜单栏中显示下拉菜单。
    • 这里出现的唯一问题是菜单选项的 OnChange,链接 - espnstar,goal.com ..- 在新窗口中打开,而不是在 iframe 本身中打开,尽管指定- OnChange="window.open(this.options[this.selectedIndex].value')" - 这似乎是正确的。 (?)
    【解决方案2】:

    语法不符合; Google 主动阻止浏览器在 IFrame 中打开它。 这是为了安全(并阻止人们劫持谷歌的内容!)

    此链接包含一些信息,但基本上解决起来很麻烦,而且 Google 不希望您这样做,因此您可能会冒着被屏蔽帐户的风险。

    http://www.codingforums.com/showthread.php?t=242978

    【讨论】:

    • 感谢 PitaJ,Russ 的 cmets。
    • 链接在 iframe 下拉菜单的新窗口中打开。我想要 [这里] (biogps.org/#goto=genereport&id=1017) 发生的完全相同的事情。 - 在 iframe 对话框顶部的物种下拉菜单中,框架会重新加载。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-02
    • 1970-01-01
    • 2013-10-03
    相关资源
    最近更新 更多