[Javascript] Opening Intranet links with a set navigation frame
Peter Brunone
peter at brunone.com
Tue Mar 20 11:17:29 CST 2001
Come to think of it, if you want to make this even more foolproof, use Esther's suggestion for when somebody calls the page all by itself; check for the presence of a frameset, and if it's not there, redirect to the frameset but with the page name in the URL as in the code below.
----- Original Message -----
From: Peter Brunone
To: javascript at LaTech.edu
Sent: Tuesday, March 20, 2001 10:50 AM
Subject: Re: [Javascript] Opening Intranet links with a set navigation frame
David,
To do this properly, you'll probably want some type of server-side logic, but it can be done from the client (just a little bit messier and not as secure).
First you'll send the URL with the page name attached in the querystring, e.g.
http://sitename/framepage.html?pagename=thispage.html
Then in the page you can either retrieve the querystring by a nice clean server-side method, or you can parse the window.location.href and get the piece after "?pagename=" to find the page you want in the frame.
From there it's just a matter of writing the necessary frameset code in the browser. There's the server-side way, depending of course on what server you're using, and then there's the client-side JavaScript method (just use document.write).
Here's a little demo I whipped up to get the page name out of the URL. You have to click the link once to get the querystring value; let me know if you have any more questions.
*******Sample code********
<html>
<head>
<title>URL Variable Snatcher</title>
</head>
<body>
<A HREF="testpage.html?pagename=booga.html">Click here</A><BR>
<FORM>
Top page: <INPUT NAME="field2" SIZE=80><BR>
Frame page: <INPUT NAME="field1" SIZE=80>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
var pageName;
var framePage;
var startIndex;
var endIndex;
var pageName = window.location.href;
var startIndex = window.location.href.indexOf("?pagename=") + "?pagename=".length;
var endIndex = window.location.href.length;
var framePage = pageName.substring(startIndex,endIndex);
document.forms[0].field1.value = framePage;
document.forms[0].field2.value = pageName;
</SCRIPT>
</body>
</html>
******* End of Sample Code ********
----- Original Message -----
From: Ciko, David
To: Javascript List (E-mail)
Sent: Tuesday, March 20, 2001 10:13 AM
Subject: [Javascript] Opening Intranet links with a set navigation frame
Let me know if this is possible...
I'd like to be able to just pass in a URL and have that page open up in a frame with a set header.
I do this now by setting up a separate file that sets the frames, but I like to have one script that I can pass the various URL's to.
Currently, most of the intranet site links we have open in separate browser windows, but I'd like to tighten-up our navigation with a navigation frame on top of all the links.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010320/ba04d5ee/attachment.htm>
More information about the Javascript
mailing list