最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Simple redirect to URL from select drop down in FACEBOOK iframe - Stack Overflow

programmeradmin4浏览0评论

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:

<form name="cityselect">
    <select name="menu" onChange="location=document.cityselect.menu.options[document.cityselect.menu.selectedIndex].value;" value="GO">
        <option value="">Leeds</option>
        <option value="">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!

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:

<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!

Share Improve this question asked Nov 3, 2011 at 22:07 matt_50matt_50 7,6454 gold badges18 silver badges13 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 18

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


<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>

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.

发布评论

评论列表(0)

  1. 暂无评论