/    Sign up×
Community /Pin to ProfileBookmark

Detecting an outer frame.

I searched through the forums and found quite a few simular matches, but none with the results I’m looking for…

Problem: When a user searches for something on google and it gives them the address to one of the pages on my site that happens to be in the center iframe, then the page loads without my main site, it only loads the iframe’d page. This is a big problem because then the users cannot access any of the sites features or navigation. I need a way to detect weather or not the main page is present from the iframed page.

Here is my site so you can see what I’m talking about:
[url]www.hlevolve.com[/url]

Example of problem:
Sample Search Result…
[url]http://search.yahoo.com/search?p=hlevolve+requests&prssweb=Search&ei=UTF-8&fr=FP-tab-web-t&fl=0&x=wrt[/url]
(Click the second link which should link you to: hlevolve.com/requests.php)

You see when you click that link (in the search results) that basically the entire site is inaccessable. You will notice I have added a line saying “The main website’s outer frame is not loaded, click here to load this frame now.” For this I was using PHP and passing a variable through the address, but this really isn’t a viable solution as I would have to change every link on my entire site to just about every page on the site.

Question: Is there a way that I can use javascript or something to automatically detect if the main page is present or not (Surrounding the framed page) from the iframed page. If it could auto detect it it would keep me from having to change so many pages, rather I could change around 15-20 pages rather than 3000+ links.

Thanks in advance :/

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@tabzterAug 26.2005 — A simple way would be to use the top object in your center iframe to check whether the top frame is the actual frame you want.

Ill go through the example for you to understand:

Imagine your main site (i.e. the page you want people to see) is called "MainPage",

such that in there you have the code [I]<title>MainPage</title>[/I]

and the center iframe (i.e. the page that shouldnt be loaded without the main site) is called "SubPage" with an HTML tag [I]<title>SubPage</title>[/I].

If you want the MainPage to be loaded up, even if someone clicks on the SubPage link then, my friend, add the following code to your SubPage:


<script language="javascript" type="text/javascript">

if (top.document.title != "MainPage")

window.location.href="http://www.yourwebsitenamehere.something";

</script>
[/QUOTE]


This script basically checks if the Main site frame page has been loaded by checking the name of the document title, if it doesnt match what it should be then the browser redirects the page to the actual website. Put your proper website address where

"http://www.yourwebsitenamehere.something"; is in the code above.
Copy linkTweet thisAlerts:
@VerticalauthorAug 26.2005 — awesome, thanks for your help! This script works exactly like I wanted ? I'll be updating the rest of my site with it later this afternoon, thanks again! ?
×

Success!

Help @Vertical 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.28,
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,
)...