Computing.Net > Forums > Programming > JS question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

JS question

Reply to Message Icon

Name: lmc
Date: October 12, 2003 at 04:23:44 Pacific
OS: Windows XP
CPU/Ram: 550/256
Comment:

hello everyone,

i am a beginner in javascript, and have a question regarding some code. do you know what this short block of code does:

if (top.location != self.location)
{
top.location = self.location;
}

i found it on some websites.

thx - LMC



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: October 12, 2003 at 05:57:37 Pacific
Reply:

I believe that it is a check to make sure that the page is not being displayed inside a frame.

The page that is doing the checking (self) is comparing it's URL (self.location) to the URL of the outer most frame (top.location). If the two are not the same, then the page is inside a frame, so it sets the top.location to it's address, thus removing itself from the frame.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: JS question

.js in head only? www.computing.net/answers/programming/js-in-head-only/3445.html

BASIC question www.computing.net/answers/programming/basic-question/8383.html

hm just a few questions www.computing.net/answers/programming/hm-just-a-few-questions/13257.html