Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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?
Reply With Quote
  #2 (permalink)  
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.
Reply With Quote
  #3 (permalink)  
Old December 13th, 2003, 10:58 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
  #4 (permalink)  
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.
Reply With Quote
  #5 (permalink)  
Old December 13th, 2003, 12:14 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
  #6 (permalink)  
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

Reply With Quote
  #7 (permalink)  
Old December 13th, 2003, 04:40 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.