JavaScriptでURLを遷移させるには、window.location.hrefに遷移したいURL文字列を設定します。
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.location = "https://www.yahoo.co.jp/"; } // --> </ script > </ head > < body onload = "OnLoad()" > < h1 >JavaScriptでURLを遷移させる</ h1 > </ body > </ html > |