質問

ドロップダウンセレクターがあり、target =" _blank"を変更する必要があります。新しいタブが開きます。

現在のコードは次のとおりです。

<SCRIPT TYPE="text/javascript">
<!--
function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
   {
   if(mySel.form.target)myWin = parent[mySel.form.target];
   else myWin = window;
   if (! myWin) return true;
   myWin.location = myVal;
   }
return false;
}
//-->
</SCRIPT>

<div id=countryselector>
    <FORM
        ACTION="../cgi-bin/redirect.pl"
        METHOD=POST onSubmit="return dropdown(this.gourl)">
        <SELECT NAME="gourl">
            <OPTION VALUE="">Select a Country...
            <OPTION VALUE="http://google.com">USA
            <OPTION VALUE="http://google.ca">Canada
        </SELECT>
        <INPUT TYPE=SUBMIT VALUE="Go">
    </FORM>
</div>

事前に感謝

役に立ちましたか?

解決

function dropdown(mySel) {
    var myVal = mySel.options[mySel.selectedIndex].value;
    if (myVal) {
        if (mySel.form.target) {
            window.open(myVal, mySel.form.target, '_attributes_');
        } else {
            window.location.href = myVal;
        }
    }
    return false;
}

_attributes _ のリストは、こちらのMozillaにあります。 または IEの場合。使用可能なオプションにはいくつかの違いがあるため、両方のリストを確認することをお勧めします。

3番目のパラメーターを関数呼び出しから除外することもできます。これは、&lt; form&gt; target =&quot; _blank&quot; のように動作する必要があります。

// behaves as if you submitted <form ... target="_blank">:
window.open(myVal, mySel.form.target);

UIの特定の部分が抑制された状態で特定のサイズと位置のウィンドウを開くために提供されているリンクで文書化されている _attributes _ のセットを使用する例を次に示します。

// this opens a window that is 400 pixels by 300 pixels
// it is positioned 100 pixels from the top and the left
// it will have no statusbar, no menu but the new window will have a toolbar:
window.open(myVal, mySel.form.target,
    'height=300,width=400,top=100,left=100,statusbar=0,menu=0,toolbar=1');
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top