Click to See Complete Forum and Search --> : retaining a page headline bar


T-Wag
03-10-2005, 08:30 AM
What I mean by this is: Click a link on my website and it takes the browser to another site, but the page loads with a thin bar at the top of the page with my website's logo and a small amount of text. That bar stays until the user closes the window.

The same thing as what hotmail does (or used to do) when you clicked a link in a recieved email. A new window opened showing the linked site but with an msn hotmail white bar accross the top of the page.

How is this done?

scragar
03-10-2005, 08:41 AM
<a href="open.html?http://www.google.com/search">link</a>

open.html:
<script type="text/javascript">
<!--
var i = window.top.location.replace(window.top.location.href.split("?")[0], "");
document.write("<frameset ...>");
document.write("<frame src='Your tops location.'>");
document.write("<frame src='"+i+"'>");
//-->
</script>

T-Wag
03-10-2005, 09:27 AM
Great, thanks :D

I'm not that experienced with javascript yet, could I ask what the ? between open.html and the google link? does

scragar
03-10-2005, 09:36 AM
it's just separating the page name and extension from the bit after it, that although read doesn't mean your host looks for a stupidly complexe file name...

T-Wag
03-10-2005, 10:13 AM
Thanks,

If you don't mind, could you tell me how I would wrap this up into a function that I could associate with the onClick event handler?

Sorry to be a bother but I really appreciate the information

scragar
03-10-2005, 10:18 AM
which one?window.self.location.href = "open.html?..."
for the first, but the second code was to be run on loading the page(otherwise frames arn't used and it causes problems)...

T-Wag
03-10-2005, 11:38 AM
It's alright I understand how it works now. I was looking at the second part of code as something that would format the open.html page from the original document, like a form passing post variables to a script.

Thanks I understand how it works now
:D

T-Wag
03-10-2005, 12:29 PM
I see my header bar, however I get this error in the content frame:

Not Found
The requested URL /source/main_layout/undefined was not found on this server

and here's the code


linkspage.html:

<a
href="link_process.html?http://www.ssta.com">South Shore Tourism Association</a>


link_process.html

<script type="text/javascript">
<!--
var i = window.top.location.replace(window.top.location.href.split("?")[0], "");
document.write("<frameset rows='10%, 90%'>");
document.write("<frame src='link_bar.html'>");
document.write("<frame src='"+i+"'>");
//-->
</script>

scragar
03-11-2005, 04:43 AM
<script type="text/javascript">
<!--
var i = window.top.location.href.replace(/^[^\?]*\?/, "");
document.write("<frameset rows='10%, 90%'>");
document.write("<frame src='link_bar.html'>");
document.write("<frame src='"+i+"'>");
//-->
</script>

That should work as well, although it's almost identicle. Do you have a link to your site then I can check it in context?

T-Wag
03-11-2005, 10:07 AM
yeah, however it's a live commercial site, so no room for leaving error pages up, so you won't see the results of the code I stated.

However,

www.southshorenow.ca

click links in the left sidebar,

Enti_t
03-11-2005, 10:17 AM
consider it in php:

link code:

link_processing_page.html?location="link_target_address_here"

that will open a page that can process everything into frames and pass a variable called location with the link address as the value.

link_processing_page.PHP

<html>
<head></head>
<body>

<?php
$location = $_GET['location'];
?>

<frameset rows="30, 1000">
<frame src="banner.html">
<frame src="<?php echo $location; ?>">

</body>
</html>

php will get the variable in the link, declare it as a variable and then echo it into the frame src. Tweak the row sizes as you will.

Hope that helps

ciao

T-Wag
03-11-2005, 12:43 PM
The php version worked great, thanks Enti_t :D

However, for the sake of discussion, I will check the javascript version that scragar provided, after all, php is serverside code, javascript is clientside, I'd like to research both options :)

scragar
03-12-2005, 08:29 AM
PHP is better, javascript can appear to be more usable in some situations but you don't want to forget about 1/10 of users unless nessesary.