Disabling "opening in a new windows" - Possible?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Disabling "opening in a new windows" - Possible?

Post by pilau »

Is it possible?
Or maybe it's possible to check (after the page has loaded) if it was opened in a new window - and then to do something like redirecting to a page, or to close the window using a javascript function.
Can I check this thing when a user loads a webpage?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can make it challenging, but impossible? not really. If they can find out the URL, which has to be possible, then they can open it in a new window. Whether the page lets them is another story, but unfortunately, that depends on Javascript.

check the cleint side board for various things, like the checking if in a frame code (page 2 right now, I think) and such...

At any rate, this is being moved to Client Side.
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Great, thanks a lot feyd.
I was talking about what you said exactly - that the page itself will prevent the surfers to see the page if it was opened from a new window.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

if a page is opened in a new window will it have the history object with itself??? :roll:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

raghavan20 wrote:if a page is opened in a new window will it have the history object with itself??? :roll:
very often, no.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Code: Select all

<script language='Javascript'>
if(opener.location && opener.location!=self.location){ 
     opener.location=self.location;
     self.close();
}
</script>
Probably not 100% reliable though (JS needs to be enabled, maybe even browser-issues etc.)
Post Reply