ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.
تاريخ النشر: 2013/07/08
Fadi Alkhateeb
من قبل Fadi Alkhateeb , Senior Front End Developer , NexTwo

window.location.href is a property from (window.location), it returns current url location in browser and when change it it will redirect the same page to the new url.
window.location.href = 'yourwebsiteurl'; window.open() is a method that will open the page you request inside it in new window.
window.open('yourwebsiteurl');

irfan shaikh
من قبل irfan shaikh , Consultant : Senior Web Designer/Front end Developer , Client : ● Impact Proximity, Dubai ● Cube Solution, Dubai ● WAC, Sharjha ● KIOEC, Kuwait ● IRIS Ltd.

window.location.href is JS property used for when you want to redirect to another page or url for Ex.
window.location.href = 'http://www.yahoo.com' will redirect to yahoo.com window.open() : open a new window with specific location or url for ex.
window.open("http://yahoo.com"); will open yahoo.com in new popup window you can define various parameter to window.open() like : height, width, scrollbar=yes/no, statusbar etc.

Osama Gamal
من قبل Osama Gamal , Software Consultant , Ministry of Interior

window.location.href gets current URL of your browser.
window.open() is a method used to open new page by specifying page url using it.

samir diab
من قبل samir diab , Je Poseur Maison , informatique

window.location.href is a property from (window.location), it returns current url location in browser and when change it it will redirect the same page to the new url.
window.location.href = 'yourwebsiteurl'; window.open() is a method that will open the page you request inside it in new window.
window.open('yourwebsiteurl

Rahif Abboud
من قبل Rahif Abboud , Information Management / Database & Web Specialist , United Nations

window.location.href is used to redirect the page to another while window.open() is use for opening the link in a new window.
window.location.href could also be used to know the current address of the page if no value is passed to it.

rajveer singh jhala
من قبل rajveer singh jhala , Software Programmer , Dotsquares technology pvt ltd

1 Window.location.href() will redirect the page to provided URL2 Window.OPen Is used to open the popup window

Muhammad Umer Jaffer
من قبل Muhammad Umer Jaffer , Lead Software Engineer , Emaratech

Window.location.href is a property which provides the URL of the current. If it is set to a different URL than the one which you are currently on then the browser window redirects to that page. Window.open is a method which gives you the option to open a page in new window. By setting parameters you can make it open in the same window.

Osama Abu Rayyan
من قبل Osama Abu Rayyan , Web Developer / Front-End Web Developer , BloomThemez

window.location.href : is not a method, it's a property to get current page url.
window.open('url') : is a method to open the url in new browser windows.

Abd-elhameed Quraim
من قبل Abd-elhameed Quraim , Software Development Team Leader , Seventh Dimension eGlobal

window.location.href is used for redirection window.open(); it opens a popup window

Munsif Mulla
من قبل Munsif Mulla , Senior UI Engineer , FreeCharge

Both have same functionality.
as both opens you a page with specified URL but the actions are different1.
window.open() -> this open you an Page for Specified URL in a new Browser Window2.
window.location.href -> this open you an Page for Specified URL in the same Browser Window

Pradeep Chand
من قبل Pradeep Chand , Web Developer , Alitum Solutions

window.location.href() is used to know the current window address or to change the current window address.
window.open is used to open a link address in new tab or new window.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟