2

How do I decide whether to open my local web page window with window.open or window.location.href?

MarredCheese
  • 17,541
  • 8
  • 92
  • 91
MDLS Itec
  • 21
  • 3
  • Possible Duplicate: https://stackoverflow.com/questions/7077770/window-location-href-and-window-open-methods-in-javascript – Naveed Ramzan Mar 22 '19 at 04:29
  • Possible duplicate of [Window.location.href and Window.open () methods in JavaScript](https://stackoverflow.com/questions/7077770/window-location-href-and-window-open-methods-in-javascript) – soorapadman Mar 22 '19 at 05:39

2 Answers2

1

Simply,

window.open() will open a new window for your passing URL in side the parentheses.

window.location.href will redirect you to the passing URL with in the same window.

0

if window.opener == null

// open by window.location.href

else

// open by window.open

MDLS Itec
  • 21
  • 3