/    Sign up×
Community /Pin to ProfileBookmark

Is page in a frame

I have a site with a simple frame layout – top, main and bottom. There are also numerous pop-up windows. Is there an easy way to find out if a page is within the Main frame or is within its own window. So…

I am a page called ShowStock.asp
Am I in a frame called Main or am I somewhere else?

Thanks for any help. At the moment I have a variable being sent in a thousand different directions to try and keep track of where the page is.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJul 11.2003 — from within the page you can do this

put the following code in the head section of the page

<script type="text/javascript">

<!--

var thisparent = this.parent;

var thisframe = this;

//see if this page has aprent frame

if(thisparent.name!=null && thisparent.name!=""){

alert("This page is opened in a frameset and the current parent frames name is = "+thisparent.name+

"nAnd this frames name = "+thisframe.name);

}else{

alert("This page is not in a frameset"+

"nAnd hence no frame name = ");

}

//-->

</script>
Copy linkTweet thisAlerts:
@WebskaterauthorJul 11.2003 — Thanks Khalid. That does the job perfectly. Do you know if there is a way to find out on the server if the page is being opened in a frame or in a new window? I want to hide some things and show others depending on whether the page is in its own window or in the Main frame. Thanks to your code I can do it client side but I wonder if it can be done on the server.
Copy linkTweet thisAlerts:
@CharlesJul 11.2003 — [font=georgia]Khalid's method will work as long as the frames all have names. For something that will work either way use [font=monospace]if (self.location == top.location)[/font].[/font]
Copy linkTweet thisAlerts:
@Khalid_AliJul 11.2003 — You are welcome webskater .

Oh BTW Charles..

try reading the question before getting blinded by your urge to (always) undermine my effort to help people.

[b]

I am a page called ShowStock.asp

Am I in a frame called Main or am I somewhere else?

[/b]


I am all ears and eyes to find out that how are you going to find out the name in the solution you suggested above?....
Copy linkTweet thisAlerts:
@CharlesJul 11.2003 — [font=georgia]Yes, I was distracted by your response that has hidden deep within it the answer to the question. But it is simply a fact that you have overlooked that not all frames have names and strictly speaking that which you have posted will not always work.[/font]
Copy linkTweet thisAlerts:
@Khalid_AliJul 11.2003 — [i]Originally posted by Charles [/i]

[B][font=georgia] But it is simply a fact that you have overlooked that not all frames have names[/font] [/B][/QUOTE]


This is has gotten ridiculously sad....

How in the heck you know what I was thinking....this is absurd...
Copy linkTweet thisAlerts:
@CharlesJul 11.2003 — [font=monospace]if(thisparent.name!=null && thisparent.name!=""){

alert("This page is opened in a frameset and the current parent frames name is = "+thisparent.name+

"nAnd this frames name = "+thisframe.name);

}else{

alert("[b]This page is not in a frameset[/b]"+

"nAnd hence no frame name = "); [/font][/quote]
[font=georgia]I suppose that you could have been intentionally trying to mislead but I choose to think that you would not do that.[/font]
×

Success!

Help @Webskater spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...