Javascript 从 FACEBOOK iframe 中的选择下拉菜单简单重定向到 URL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8002512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 04:20:48  来源:igfitidea点击:

Simple redirect to URL from select drop down in FACEBOOK iframe

javascriptfacebook

提问by matt_50

I'm sure this shouldn't be so hard!

我相信这不应该那么难!

I've been struggling with facebook's javascript: I need to redirect to a URL based on the value in a select drop down menu, something like:

我一直在为facebook 的 javascript苦苦挣扎:我需要根据选择下拉菜单中的值重定向到一个 URL,例如:

<form name="cityselect">
    <select name="menu" onChange="location=document.cityselect.menu.options[document.cityselect.menu.selectedIndex].value;" value="GO">
        <option value="http://www.leeds.html">Leeds</option>
        <option value="http://www.manchester.html">Manchester</option>
    </select>
</form>

Can anybody help me get this working? I've had good look though the facebook dev forum and docs but either don't understand what needed or can't find the answer!

有人可以帮我解决这个问题吗?我已经很好地看了 facebook 开发论坛和文档,但要么不明白需要什么,要么找不到答案!

回答by Shawn E Carter

Try {} this.options also your urls are mistyped. http://www.leeds.htmlshould be http://www.leeds.com, not sure if that is related but just wanted to point that out just in case.

尝试 {} this.options 您的网址也输入错误。http://www.leeds.html应该是http://www.leeds.com,不确定这是否相关,但只是想指出来以防万一。



<form name="cityselect">
    <select name="menu" onChange="window.document.location.href=this.options[this.selectedIndex].value;" value="GO">
        <option selected="selected">Select One</option>
        <option value="http://www.leeds.com">Leeds</option>
        <option value="http://www.manchester.com">Manchester</option>
    </select>
</form>


Parent Frame:

父框架:

<form name="cityselect">
    <select name="menu" onChange="top.location.href=this.options[this.selectedIndex].value;" value="GO">
        <option selected="selected">Select One</option>
        <option value="http://www.leeds.com">Leeds</option>
        <option value="http://www.manchester.com">Manchester</option>
    </select>
</form>

回答by Sandeep Mishra

how to remember selection after redirect.

重定向后如何记住选择。

for example

例如

let us suppose there are many city name in drop down. when i select city name in drop down then relevant page should appear on website and selection of current city should remain on redirected page until selection not changed

让我们假设下拉列表中有很多城市名称。当我在下拉列表中选择城市名称时,相关页面应出现在网站上,当前城市的选择应保留在重定向页面上,直到选择未更改

all redirect on same domain with subdomain all sub domain layout same dropdown will be available on all pages of website.

与子域在同一域上的所有重定向所有子域布局相同的下拉列表将在网站的所有页面上可用。