JavaScriptで新しいページを開いてURLを遷移させるには、window.openに遷移したいURL文字列と、"_blank"を指定します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <!doctype html> < html > < head > < meta charset = "UTF-8" > < script type = "text/javascript" language = "javascript" > <!-- function OnClickButton() { // URLの遷移(新しいページを開く) window.open( "https://www.yahoo.co.jp/", "_blank" ); } // --> </ script > </ head > < body onload = "OnLoad()" > < h1 >JavaScriptでURLを遷移させる(新しいページを開く)</ h1 > < input type = "button" value = "新しいページを開いてURLを(https://www.yahoo.co.jp/)へ遷移させる" onclick = "OnClickButton();" > </ body > </ html > |