How to use window.location.replace in jquery or javascript
Solution 1
The problem is somewhere in the code around that. You need to call that code in the old window.
If you want to call it in the chat window, try:
window.opener.location.replace('http://mywebsite.com/index.php?route=information/contact');
window.close()
Solution 2
Use the href
property instead:
window.location.href = 'http://mywebsite.com/index.php?route=information/contact';
Solution 3
You can use simple javascript code like this: window.location.href = "SOME URL" it will do the same think. .
Haroon
A Web developer primarily focusing on PHP development and a tech resource blogger. Please read my blog post on stackoverflow is a huge blessing for the world and also check out my other blogs on my websites: https://haroonejaz.net/ and https://stuffaroundtheweb.com/ Click here to check yours
Updated on July 25, 2022Comments
-
Haroon almost 2 years
I have a website for which I have implemented livechat, when user clicks on livechat link it opens a new window that is fine. I want to do is when no operator is online then it should not open a new window when livechat link clicked instead it should redirect to the contact us page of the website in the same window in the currently opened tab, Is it possible? I do not know how is it possible, what I have tried is this , it redirects to this page but opens in a new window.
window.location.replace('http://mywebsite.com/index.php?route=information/contact');