I am using the code shown in the images below. I have tried many ways like closing login window, before opening a new one. I have also tried many ways like window.open("index.HTML", '_self', false)
and window.location.replace("index.HTML")
but they are not working at all:

- 5,753
- 72
- 57
- 129

- 79
- 10
-
What happens when you try `window.open("index.html", '_self', false)`? Do you get a new window open? – An0nC0d3r Dec 01 '15 at 22:59
-
it refreshing the same "Login" window and not opening "index.html" – Zaid Dec 01 '15 at 23:03
-
And what if you did `window.open("https://www.google.com", '_self', false)`? Do you see the google site or Login page? If you see Google, you have a path relativity issue. You may wish to try `window.open("/index.html", '_self', false)` or `window.open("../index.html", '_self', false)`... – An0nC0d3r Dec 01 '15 at 23:07
-
Or fully qualify it... `window.open("http://www.yourdomainname.com/index.html", '_self', false)` – An0nC0d3r Dec 01 '15 at 23:09
-
Same results...not opening google.com – Zaid Dec 01 '15 at 23:09
-
1I really don't know how taking a screenshot, cropping it, uploading it and then copy paste that link is easier that just copy pasting the code. – gre_gor Dec 01 '15 at 23:23
-
1Why screenshot? Copy the code, and paste it here. – ataravati Dec 01 '15 at 23:45
2 Answers
I usually use window.open("http://www.example.com", "_blank")
Also check your pop-up blocker since it will most probably detect this as popup and block it.
If not then use a monkey patch which is create an html anchor tag with target="_blank". Hide it with CSS visibility: hidden
, then invoke the click event using JS.
Read more about popups and blocking in this answer. If your window.open
event was not triggered by a click then most probably it would be blocked.
-
He wants to open the window in the same tab To do this, one should not use `window.open(..., "_blank")` because this will open up the page in a new **blank** window – Viraj Shah Dec 01 '15 at 23:55
What you want to do, if I am not mistaken, is open a new webpage but using the same window (or tab)... To do this, you should modify the window.location
property.
For example:
window.location = "new_page.html"
This will take you to new_page.html
.
If your current location is: /users/muhammad/index.html
Then the page will take you to: /users/muhammad/new_page.html
Leave a comment if you have any questions!
=)

- 754
- 5
- 19
-
Exactly ! this is what i want..But the solution you provided is not working..i already tried this one..it's not taking me to new_page..but refreshing the old one. – Zaid Dec 02 '15 at 00:12
-
-
You will be prompted with a console. There type your command: `window.location = ...`, and leave a comment with the output of that command – Viraj Shah Dec 02 '15 at 00:17
-
well on typing window.location = "index.html" on console . it's taking me to the page "index.html" – Zaid Dec 02 '15 at 00:30
-
thats odd behavior... can you upload the code to dropbox, or google drive and comment a link so that I can further inspect the code – Viraj Shah Dec 02 '15 at 00:32
-
I got it...this happens only when i use Input of type="text"....but when i replace it with type ="email" ,it works fine ...i don't know why it's happening – Zaid Dec 05 '15 at 10:39