JavaScript の メソッドwindow.location.href
とメソッドの違いは何ですか?window.open ()
ベストアンサー1
window.location.href
はメソッドではなく、ブラウザの現在の URL の場所を示すプロパティです。プロパティの値を変更すると、ページがリダイレクトされます。
window.open()
新しいウィンドウで開きたい URL を渡すことができるメソッドです。例:
window.location.href の例:
window.location.href = 'http://www.google.com'; //Will take you to Google.
window.open() の例:
window.open('http://www.google.com'); //This will open Google in a new window.
追加情報:
window.open()
追加のパラメータを渡すこともできます。参照:window.openチュートリアル