/    Sign up×
Community /Pin to ProfileBookmark

frame elements, javascript, and php

I got this javascript code from the HTML Goodies website that lets my frame elements redirect to their frame managers if they are viewed outside of the manager.

[QUOTE]

<SCRIPT LANGUAGE=”javascript”>
if (self==parent)
{
document.write(‘Sorry, this page is just one frame element.’)
document.write(‘You will now be redirected to the frame manager’)
document.write(‘<META HTTP-EQUIV=”refresh” CONTENT=”5; URL=marquette.htm”>’)
}
</SCRIPT>

[/QUOTE]

However, I also use php server side includes (SSI) to create a printable version out of these frame elements. Only, the javascript doesn’t allow me to put the frame elements into one page.

[I]How can I fix it?[/I]

I guess this is best explained by looking at an example of my site:

Intended result (but without the necessary javascript):
[url]http://www.pmhauer.com/affiliation.php[/url]

What’s going on now:
[url]http://www.pmhauer.com/community.php[/url]

Thanks for any help or suggestions.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarApr 21.2005 — first of all your javascript is depreciated:[code=php]<script type="text/javascript"><!--
if (window.self==window.parent){
document.write('Sorry, this page is just one frame element.')
document.write('You will now be redirected to the frame manager')
setTimeout("window.top.location.href = window.self.location.href;", 5000);
};
//-->
</script>[/code]
and secondly, try doing a querystring(so you would have pages like: community.php?print which would not redirect you).[code=php]<?
if(!isset($_GET['print'])){//if we are not going to print or bookmark it
?><script type="text/javascript"><!--
if (window.self==window.parent){//check if they are not in frames
document.write('Sorry, this page is just one frame element.')
document.write('You will now be redirected to the frame manager')
setTimeout("window.top.location.href = window.self.location.href;", 5000);
//forward them out.
};
//-->
</script><?
};
?>[/code]
Copy linkTweet thisAlerts:
@pmhauerauthorApr 21.2005 — Hey thanks! It seems to work (of course). Only, my frame elements don't seem to know where to load when they are viewed outside of their frame manager.

Example: http://www.pmhauer.com/marquette_header.htm

Do I need to specifically rename these 'window.top.location.href' or 'window.self.location.href' for my site? If so, what to?

Thanks again.
Copy linkTweet thisAlerts:
@scragarApr 22.2005 — sorry, I forgot to add something.

[code=php]<?
if(!isset($_GET['print'])){//if we are not going to print or bookmark it
?><script type="text/javascript"><!--
if (window.self==window.parent){//check if they are not in frames
document.write('Sorry, this page is just one frame element.')
document.write('You will now be redirected to the frame manager')
setTimeout("window.top.location.href = 'YourFileManagersName followed by a questionmark.'+window.self.location.href;", 5000);
//forward them out.
};
//-->
</script><?
};
?>[/code]
EG:
[code=php]<?
if(!isset($_GET['print'])){
?><script type="text/javascript"><!--
if (window.self==window.parent){
document.write('Sorry, this page is just one frame element.')
document.write('You will now be redirected to the frame manager')
setTimeout("window.top.location.href = 'fManager.php?'+window.self.location.href;", 5000);
};
//-->
</script><?
};
?>[/code]
Copy linkTweet thisAlerts:
@pmhauerauthorApr 22.2005 — coolio.

thanks!
×

Success!

Help @pmhauer 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 6.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ,
analytics: Fullres
});

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: @Marika,
tipped: article
amount: 1000 SATS,

tipper: @hatem774,
tipped: article
amount: 1 SATS,

tipper: @nearjob,
tipped: article
amount: 1000 SATS,
)...