PDA

View Full Version : Stopping pages from opening in another website's frames


twilight
12-06-1999, 06:14 AM
Hi. Is there a way to stop my web pages from opening up in a frame in someone else's website? I don't mind them putting a link to my site, but would rather my page doesn't open up in a frame on their site.

Thanks.

Drew
12-06-1999, 08:30 AM
You can use this javascript to break out of frames:

if (window != top) top.location.href = location.href;


_/ drew /_

Armand
12-06-1999, 10:19 AM
Well you can go the ole' "break out of frames" features (html or javascript as Drew suggested) but my personal opinion is that if someone's doing this it's usually because 1) they don't know what they are doing html wise (my biggest source of this for my site...newbies); 2) want to make your content look like it's theirs; 3) or are really desperate to keep people at their site.[nbsp][nbsp]I often think it's best to e-mail the webmaster since the "break out" option requires the user to find that link and use it, which they may or may not.

Plus if you have people linking to different pages, it's sort of pain in butt to edit your whole to put "break out" link everywhere you know.[nbsp][nbsp]Keeping up on referrers from stats info helps greatly to find the culprits if any.

Just one tired person's 2 pennies for the whole day.[nbsp][nbsp]back to the cave I crawled out of...lol ;)[nbsp]

Justin
12-06-1999, 11:43 AM
Armond - the solution Drew shows does not require the user to click a link to "break out" - it is done automatically. If it detects that the URL to "_top" does not match that page's URL, it knows it must be in a frame (although this can cause problems I think if it happens to be within a popup window with a different name)... The FutureQuest site has had that snippet of code in it for a while now, and it works automatically - in fact it actually helps to cover up the fact that the linking page is improperly coded ;)

I have gotten "Permission Denied" errors with that snipped at one point before - I think it was the "Ask Jeeves" search engine, which pulls the result pages within a frame... it actually showed a JavaScript error. I think they have something coded to prevent that from working.

But what might work is this: if it detects that it is not the parent frame, it can open it's own URL in a new window, and go back in the current window - eg, it would appear that the link just opened in a new window... I might test this theory later on...

------------------
Justin Nelson
FutureQuest Support

Armand
12-07-1999, 12:19 AM
Ooopps... should have realized my error since I use the code on my own main page.[nbsp][nbsp]Guess that's what I get for opening my mouth after working all night and before hitting the sack.[nbsp][nbsp]But the point of having to add all that extra code to every page on your site still stands IMHO.[nbsp][nbsp]Didn't realize any search engine or big site would pull that BS.

Justin
12-07-1999, 01:01 AM
What's the difference between adding a one line JavaScript and adding any other element to an entire site? Wow - I could not imagine updating page after page for any update...

This is why, on every site I work with (5 I can think of off the top of my head) uses a common header and footer. The header always contains all JavaScript, CSS, and the navigation and table layouts. The footer contains the copyright and table endings etc... the content pages have only text and
tags - that's it. No <FONT> tags (I despise <FONT> and

tags - much prefer site-wide CSS and simple
's)...

I can add a new page without using a template or remembering the format - in fact, you could probably take a php page from any one site, upload it to another of my sites, and it would work with the new site's formatting - as long as it calls header.php and footer.php ;)[nbsp][nbsp] But adding a page is not the best part - it's when situations like this come up... new JavaScript, CSS idea, or a change of font/color preference requires editing 1 or 2 files...

Unless I am building a really small (less than 10 pages) site, I will always use a header/footer to wrap each page in...

------------------
Justin Nelson
FutureQuest Support

twilight
12-08-1999, 05:18 PM
Hi again. Thanks, it worked. Am happy now.

CherylChase
04-14-2000, 11:00 AM
Justin talked about isolating his header/footer/navigation in a single site-wide file. I would like to do this, and I've been hunting without much success for an example of the code, or a template that I can modify for my site. I want to add a uniform appearance and navigation, but webmaster isn't my primary function. I don't want to spend lots of time learning the technology.

Can anyone point me to a sample? (The code, not just the site.)

I'm also wondering how it is that major commercial sites are able to do this and yet have only &quot;.html&quot; as their file extensions, rather than &quot;.shtml&quot; or &quot;.php&quot;

Cheryl

Maverick
04-14-2000, 11:47 AM
You can make any page like .htm or .html server-parsable for included files, but it's not usually a good idea as that increases the server workload. The best way is to do it with the normal file types like .php or .shtml

There are millions of ways to add header/footer/nav info, but the easiest are:

In regular .shtml files with SSI:
<!--#include file=&quot;header.inc&quot; -->

In PHP:
<?PHP include(&quot;header.inc&quot;)?>

I structure my pages this way:

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>

[nbsp][nbsp]<TITLE></TITLE>
[nbsp][nbsp]<META>
[nbsp][nbsp]<META>
[nbsp][nbsp]<!-- etc etc etc -->


Then, in the included file:


</HEAD>
<BODY ETC>

Page Layout Info
Navigation Info
ETC


And then the content starts:

That structure allows a lot of different info to be changed by changing the header.inc file:

The BODY tag can be changed to switch backgrounds, colors, fonts, etc

The Navigation info can be updated.

The layout can be altered by adjusting the master table.

The same hold true for footer info. Although it's not nearly as critical as the header file, it's still nice to have the footer as an include. So the page structure when done looks something like:


<HTML>
<HEAD>

[nbsp][nbsp]<TITLE></TITLE>
[nbsp][nbsp]<META>
[nbsp][nbsp]<META>

[nbsp][nbsp]<!--#include file=&quot;header.inc&quot; -->

[nbsp][nbsp]Your content

[nbsp][nbsp]<!--#include file=&quot;footer.inc&quot; -->

</BODY>
</HTML>



There are hundreds of other ways to structure the site, but that's pretty simple and allows great flexability for changing info across the entire site by editing a single file. Keep in mind that when editing that type of page locally, you need to be previewing them through some sort of server software so that the includes are parsed. Otherwise, what you see is most definitely NOT what you get.