[Javascript] Opening Intranet links with a set navigation fra me

Ciko, David david_ciko at merck.com
Tue Mar 20 11:35:21 CST 2001


Thanks for all the help...
 
I think I've almost got it, but the code I'm using just isn't changing the
URL. I know it's parsing the url, but where am I going wrong. 
 
The reason I can't use Esters suggestion is that the content is controlled
by numerous different providers and I cannot modify the code they have for
their various sites.
 
*****sample code*****
 
<html>
<head>
 <title>URL Variable Snatcher</title>
</head>
 
<body>
<A HREF="testpage.html?pagename=test2.html">Click here</A><BR>
<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.write('<html><head><title>Test</title></head><FRAMESET ROWS="70,*"
BORDER="0" FRAMESPACING="10" FRAMEBORDER="no">')
document.write('<FRAME SRC=""frame_TSC_heading.stm"" NAME="heading"
SCROLLING=no NORESIZE MARGINWIDTH=2 MARGINHEIGHT=10>')
document.write('<FRAME SRC="' + framePage + 'NAME="MAIN" SCROLLING=no
NORESIZE MARGINWIDTH=0
MARGINHEIGHT=0></frameset><noframes></noframes></html>')
</SCRIPT>
 
</body>
</html>

*****end sample code*****
 
 

-----Original Message-----
From: Peter Brunone [mailto:peter at brunone.com]
Sent: Tuesday 20 March 2001 11:50
To: javascript at LaTech.edu
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
<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,  <mailto:david_ciko at merck.com> David 
To: Javascript  <mailto:javascript at LaTech.edu> 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/0d35e157/attachment.htm>


More information about the Javascript mailing list