Hello,
I'm trying to use a cookie to set what the main frame will load as content. Basically, if the user enters the site one way I need the main frame to display a specific page that contains the information stored in the cookie as part of the filename of the source. If they enter a different way I would like the default page to load. Currently the header loads fine as it is hard coded into the page, but the main frame loads nothing. At this point the pages that load as header and main are unimportant, I more just need the code to work and I'll worry about correct pages later.
I've enclosed all of my code below. I'm new to javascript and hope I'm just missing something simple.
Any help would be greatly appreciated.
Thanks,
Nathan
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
cookie_name = "dataCookie";
var YouWrote;
var mainpage;
function getName() {
if(document.cookie)
{
index = document.cookie.indexOf(cookie_name);
if (index != -1)
{
namestart = (document.cookie.indexOf("=", index) + 1);
nameend = document.cookie.indexOf(";", index);
if (nameend == -1) {nameend = document.cookie.length;}
YouWrote = document.cookie.substring(namestart, nameend);
return YouWrote;
}
}
}
function getpage(){
YouWrote=getName();
if (YouWrote == "dataCookie")
{YouWrote = "Nothing_Entered"}
if (YouWrote == "Nothing_Entered")
{window.main.src="mainframespecific.htm"}
if (YouWrote = "Nothing Entered")
{window.main.src="mainframedefault.htm"}
}
</SCRIPT>
<base href="~~base_href$~~">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Welcome to the Main Page</title>
<script language="JavaScript" src="iwwiab.
js"></script>
</head>
<frameset rows="175,*" frameborder=0 framespacing=0 border=0 >
<frame src="mainpageheader.htm" scrolling="no" name="top" marginwidth="0" marginheight="2">
<frame name="main" marginwidth="0" marginheight="2">
<script>getpage()</script>
<noframes>
<body>
<p>This page requires a frames capable browser.</p>
</body>
</noframes>
</frameset>
</html>