 |
| 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
|
|
|
|

December 12th, 2003, 06:17 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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
|
|

December 13th, 2003, 10:06 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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.
|
|

December 13th, 2003, 10:58 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

December 13th, 2003, 11:09 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Or maybe the intent is to prevent hijacking?
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

December 13th, 2003, 12:14 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

December 13th, 2003, 03:31 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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
|
|

December 13th, 2003, 04:40 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|
 |