【问题标题】:Combo box link is not working after clicking单击后组合框链接不起作用
【发布时间】:2016-01-14 16:22:30
【问题描述】:
<form name="mycombowopt">
    <select  name="example" size=1>
        <option value="http://javascriptkit.com">JavaScript Kit</option>
        <option value="http://cnn.com">CNN</option>
        <option value="http://geocities.com">Geocities</option>
   </select>&nbsp;
   <input type="button" value="Go!" onClick="gothere()"> <br>
   <input type="checkbox" name="windowoption" value="ON">Open in alternate window</p>
</form>

<script language="javascript">
<!--


function gothere(){
    var thebox=document.mycombowopt
    if (thebox.windowoption.checked){
        if (!window.newwindow)
        newwindow=window.open("")
        newwindow.location=
        thebox.example.options[thebox.example.selectedIndex].value
    }
    else
    location=
    thebox.example.options[thebox.example.selectedIndex].value
}
//-->
</script>

这段代码有什么问题?在我的 [问答网站][1] 上链接“Go”后,组合框无法正常工作。

  [1]: http://www.ihavesolved.com/

您能否提供以下组合框的代码:-

背景=白色
标题:- 合作伙伴网站
下拉框内的链接 = 我已解决 (url=www.iнaveѕolved.coм), Space Amigos
(spaceamigos.com) 和 Surak.szh.kz (url=Surak.szh.kz)

链接必须在新窗口中打开,并且链接必须是 nofollow。

在此先感谢 :)

【问题讨论】:

  • 背景 = 白色 标题:- 合作伙伴网站。
  • 链接必须在新窗口中打开并且链接必须是nofollow。提前致谢:)

标签: combobox


【解决方案1】:

你可以使用

window.open

而不是

location

这个 javascript 代码对我有用。

function gothere(){
        var thebox=document.mycombowopt
        if (thebox.windowoption.checked){
            if (!window.newwindow)
            //newwindow=window.open("")
            //newwindow.location=thebox.example.options[thebox.example.selectedIndex].value

            window.open(
              thebox.example.options[thebox.example.selectedIndex].value,
              '_blank' // <- This is what makes it open in a new window.
            );
        }
        else{
            //location=thebox.example.options[thebox.example.selectedIndex].value   
            window.open(
              thebox.example.options[thebox.example.selectedIndex].value,
              '_blank' // <- This is what makes it open in a new window.
            );
        }

    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-13
    • 2016-01-02
    • 2016-05-18
    • 1970-01-01
    相关资源
    最近更新 更多