govinda govinda - 2 years ago 57
HTML Question

preventing external page from redirecting MY (parent) page

Using the latest version of Chrome on Mac OS 10.7.

I assume it is some clever javascript that is enabling the folks at this webpage: close my (the parent) page which opened their ( page in the first place.
I did not open them with javascript, but with an

tag with the

If I disable javascript, then the behavior stops.

<a href="" target="_blank"></a>

I would expect the page at to simply open in another tab/window... but what I find is that as soon as the new browser tab opens, it closes, and then my page (the parent tab/window) gets redirected to the page.

Kinda rude.

Can someone point me to what code enables them to do that? And how do I prevent it? (Assuming I want a link to behave as expected, such as in my demo page.)

Answer Source

This is the script they are using:

function redirect_page(){if (window.opener) { window.opener.location.href = '/home.html'; window.close(); } else { location.href = '/home.html'; }}

As to how to circumvent it (just an idea):
Create your own blank page, with it's source set to about:blank. When it loads (or after a time-out) you could write some code to that window that will then open the offending link. Then the offending link just closes your buffer-page. F*ck 'm!! Power to the user!

Edit: looks like you could also name your page home.html hehe, but that is not such a workable solution..

Final Edit: SIMPLE LOGIC people...
<a href="" target="_blank"></a>
works for everyone, no javascript needed.
See this working jsfiddle example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download