[removed].href and window.open () methods in JavaScript

前端 未结 6 871
北海茫月
北海茫月 2020-11-22 10:48

What is the difference between window.location.href and window.open () methods in JavaScript?

6条回答
  •  感动是毒
    2020-11-22 11:46

    There are already answers which describes about window.location.href property and window.open() method.

    I will go by Objective use:

    1. To redirect the page to another

    Use window.location.href. Set href property to the href of another page.

    2. Open link in the new or specific window.

    Use window.open(). Pass parameters as per your goal.

    3. Know current address of the page

    Use window.location.href. Get value of window.location.href property. You can also get specific protocol, hostname, hashstring from window.location object.

    See Location Object for more information.

提交回复
热议问题