MDLS Itec
MDLS Itec

Reputation: 21

window.open vs window.location.href

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

Upvotes: 2

Views: 1789

Answers (2)

MDLS Itec
MDLS Itec

Reputation: 21

if window.opener == null

// open by window.location.href

else

// open by window.open

Upvotes: 0

Bathiya Seneviratne
Bathiya Seneviratne

Reputation: 302

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.

Upvotes: 1

Related Questions