<button onClick="location.href='linked.html'">例1</button>
function 例1(リンク先URL) { location.href = リンク先URL; } ----- <button onClick="例1('linked.html')">例2</button>
function 例2(リンク先URL, 表示ウインドウ) { window.open(リンク先URL, 表示ウインドウ); } ----- <button onClick="例3('linked.html', '_blank')"> 例2(scriptあり)</span> ===== <button onClick="window.open('linked.html', '_blank')">例2(scriptなし)</span>
function 例3(リンク先URL, 表示ウインドウ, パラメータ) { window.open(リンク先URL, 表示ウインドウ, パラメータ); } ----- <button onClick="例3('linked.html', '_blank', 'width=300,height=200,scrollbars=yes')">例3(scriptあり)>/butto<> ===== <button onClick="window.open('linked.html', '_blank', 'width=500,height=400,scrollbars=yes')">例3(scriptなし)</button>
上のように「名称=機能」の形式で記述します。順序は任意で「,」で区切ります。
パラメーター | 値 | 意味 | 無指定解釈 |
---|---|---|---|
width | ピクセル値 | ウィンドウ幅 | |
height | ピクセル値 | ウィンドウ高さ | |
left | ピクセル値 | ウィンドウ位置左 | |
top | ピクセル値 | ウィンドウ位置上 | |
resizable | yes/no | リサイズ可否 | yes |
scrollbars | yes/no | スクロールバー有無 | yes |
menubar | yes/no | メニューバー有無 | yes |
titlebar | yes/no | タイトルバー有無 | yes |
toolbar | yes/no | ツールバー有無 | yes |
location | yes/no | アドレスバー有無 | yes |
status | yes/no | ステータスバー有無 | yes |
function 例4() { var リンク先URL = document.例4フォーム.リンク先.value; location.href = リンク先URL; } ----- <form name="例4フォーム"> <label>リンク先<input type="text" name="リンク先" value="linked.html"></label> <button type="button" onClick="例4();">例4実行</button> </form>