Jump to content

Help with forcing my pages into frames


skivvia

Recommended Posts

HiMy website is set up with a top (header), left (menu) and body (body) frame layout. I have about 20 different pages (in different folder locations, such as mysite/holidays/body.htm, mysite/holidays/tasmania/body.htm, mysite/videos/body.htm etc) that load into the body frame, while the top and left frames do not change. I am having problems with the javascript to make sure that these pages always open within the frameset. At current, when I open a page that should be forced into a frameset, it either opens in a page of it's own, or it tries to open the "index.htm" page at the wrong header level (i.e. mysite/holidays/index.htm rather than mysite/index.htm).I have based my javascript on the script available here: http://www.webreference.com/js/column36/forcing.html and the concept works fine using the example on that webpage.I am still playing around with this script on my PC to get it working so have not uploaded it to my website yet, but I have included what I think is the relevant code below. thanksSkivviaMy frameset page looks like this:

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>4WD custom tips and tricks</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><meta name="description" content="Travel adventurers: Travel ideas and 4WD modifications" /><meta name="keywords" content="4WD,Patrol, bla bla bla" /><meta name="author" content="White sands" /><meta name="revisit-after" content="15 days" /><meta name="document-classification" content="Internet" /><meta name="document-rating" content="General" /><meta name="robots" content="index,follow" />	<script language="javascript" type="text/javascript"><!--var ar0 = "left.htm";var ar1 = "top.htm";var ar2 = "body.htm";var str = location.search;var pos = str.indexOf("&");if (pos != -1) {  var num = str.substring(pos + 1, str.length);  window["ar" + num] = str.substring(1, pos);}// --></script><link rel="stylesheet" type="text/css" href="style.css" /></head><script LANGUAGE="JavaScript"><!--document.write('<frameset cols="100%" border=0 frameborder="no" color="ff0000" framespacing="0" noresize="noresize">',	'<frameset cols ="166,*">',		'<frame src="', ar0, '" name="left"scrolling="no" noresize="noresize">',		'<frameset cols="100%">',			'<frameset rows="160,*">',				'<frame src="', ar1, '" name="top" scrolling="no" noresize="noresize">',					'<frame src="', ar2, '" name="body" scrolling="yes" noresize="noresize">',			'</frameset>',		'</frameset>',	'</frameset>','</frameset>','<NOFRAMES>','<body>',          '<p>Travel adventurers: Travel ideas and 4WD modifications</p>',      '  <p> Your browser does not support frames. Please enable frames to view this site</p>','</body>','</NOFRAMES>');// --></SCRIPT><!-- Thanks to webreference for the above javascript, available at URL: [url="http://www.webreference.com/js/column36/forcing.html"]http://www.webreference.com/js/column36/forcing.html[/url]// --></html>

and the javascript in the head of my html pages (for example www.mysite/holidays/body.htm) looks like this:

<script language="javascript" type="text/jscript" ><!--if (top.location.href.indexOf("index.htm") == -1)  top.location.href = "index.htm?holidays/body.htm&2";// --></script>

Link to comment
Share on other sites

It's possible the trouble is in this line of code:

top.location.href = "index.htm?holidays/body.htm&2";

You say this appears in the script for www.mysite/holidays/body.htm and similar pages, many of which appear in unique directories. In this case, the server will look for index.htm in the "holidays" directory, since that is where "body.htm" is located. Is that in fact where "index.htm" is? If not, you'll have to change the path in the line of code I quoted.

Link to comment
Share on other sites

Thanks Deidre's Dad, that is what I was suspecting.body.htm is located in the 'holidays' directory, but 'index.htm is located up one directoryHow do I refer to a file up a directory using javascript? In my code I have refered to it as holidays/body.htm, and this did not work, do I use ../body.htm or some javascript?Thanks

Link to comment
Share on other sites

top.location.href = "../index.htm?holidays/body.htm&2";

Link to comment
Share on other sites

Now that my pages are behaving correctly within their frames... my next issueIf someone enters my site via say the ...holidays/body.htm page (from an external link or search engine), the navigation bar displays www.mysite/working/index.htm?holidays/body.htm&2This is all fine, until they navigate to a different part of the website; the navigation bar continues to display the original url of www.mysite/working/index.htm?holidays/body.htm&2Is there a way I can get the URL to update relating to which page is displayed, or otherwise revert to the generic www.mysite/index.htm when a person moved away from the initial page via which they entered the site.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...