简体   繁体   中英

when clicking on page after closing a window opened via window.open the window reopens

I use the following to open a new window:

var win = window.open('URL HERE' , type ,'width=1100,height=500,left=200,top=200');

The reason I assign a variable to it is because it allows me to do other things with the variable such as actions on close (which I am not using in this case).

The window opens just fine. I can do everything I need to do inside the window. But the problem occurs when I close the window: The window closes but reopens automatically when i click anywhere on the parent page.

This happens if I click the browsers "x" on the new window, or even if I click a link that that includes onclick="window.close()" , and it happens every single time I try this. It's not sporadic at all.

What am I missing?

Found it!

Avoid using onchange and onblur together - even though some people post that this fixes some onchange problems that occur on ios devices.

At some point in the past I was dealing with an issue with iphone and ipad not opening a window when running an onchange event. Everyone kept posting about using onblur events on those devices. That didn't fix the problem but I had left an onchange and an onblur event inside the select dropdown by accident not realizing that was what it was doing.

What was happening was that I was running the window.open when the selection changed, and then it was rerunning window.open when the window lost focus which resulted in another window opening when refocusing parent page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM