Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2003, 06:17 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default Target for main frame?

Here's the deal:

A window opens in which there's a top and bottom frame.
The top frame needs to stay there while the user browses the internet in the main page.

When a link is clicked in the main page or the browser is redirected, the top frame disappears... Is there a way with JavaScript (or just about anything else, really) to stop this??

Thanks in advance

Snib

__________________
-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old December 13th, 2003, 10:06 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Normally any link on a page in a frame keeps the new page in the frame. Only if the link has a "target" attribute value that points to another frame, a non-existent frame/window or one of a set of predefined names will the page not stay in the same frame. Check the "target" attribute in the links.

<a href="..." target="<frame/window name>">click me</a>

Also, there is a tag that you can put in the <head> tag area. It can specify the base href and target for all links on the page.

<base href="..." target="<frame/window name>">

You don't need to do anything special to make this work, but there are things that can make it not work. So check those out and let us know if you still are having a problem.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 13th, 2003, 10:58 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think what Snib is trying to accomplish is a Frame hijack. That is, capture the user browsing other pages on different URLs and servers inside his own frame, right?

If that's the case, there is not much you can do about that. A lot of sites have script like BrakeOutOfFrame that makes sure the page is always loaded in the top window, instead of someone else's frame.

If you elaborate a bit about what you're doing, and how you want things to look, we may be able to come up with other ways to do the same thing.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 13th, 2003, 11:09 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Or maybe the intent is to prevent hijacking?

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 13th, 2003, 12:14 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hmmm, yeah, tout est possible, but:

Quote:
quote:The top frame needs to stay there while the user browses the internet in the main page.
makes me think it's the other way around......

I may be a bit suspicious, though ;)

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 13th, 2003, 03:31 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Sorry, you're kind of losing me on this hijack stuff...

I wanted a page that opened a fullscreen window to browse the internet in, but I was going to include a small top frame that has some links to parts of my site (along with a "close top frame" button).

An example is Google's translate action. It opens a frames page with their site on top (small) and the translated page on the bottom (big). The top also has a back button, etc.

Thanks for helping

Snib

 
Old December 13th, 2003, 04:40 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What I meant with hijacking is that some people reuse someone else's web site and try to take credit / revenues / whatever for it. By putting someone else's web site inside a frame in your site, you can make your visitor believe that *you* created its content.

I thought you were trying to accomplish something like that.

Still, you can't do too much about it. If the inner frame is from another source, and specifies _top as the target for a link, it will appear in the top window. It looks like the Google translations can work around this, but it doesn't. If you look at an example link in the lower frame, you'll see that the targets are referencing links owned by Google. It's a server side thingy that does the translation, and they change the links as well.

Think about what your visitor wants: What would be their added benefit of browsing the Internet while still in your site. If the only answers to that question are related to *your* benefit, you shouldn't do it. If it's for the user's benefit, you may need to do some fancy server side stuff, like getting the pages for them on the server, and passing the (parsed / changed) content back to the lower frame.

Imar




---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set one frame src from other frame akumarp2p ASP.NET 1.x and 2.0 Application Design 2 March 13th, 2007 04:13 AM
parsing form data from frame to other frame audio-catalyst Classic ASP Basics 5 January 3rd, 2006 02:57 PM
Call right frame Page_Load event from left frame. ochanarachel Classic ASP Basics 0 January 28th, 2005 05:13 AM
Use cookie to set main frame npepin Javascript 0 October 18th, 2004 02:01 PM
Open framed html and target frame fs22 Javascript How-To 2 May 5th, 2004 04:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.