Click to See Complete Forum and Search --> : Need Help With Frames!!


AustereLove
07-03-2005, 12:38 AM
http://www.freewebs.com/austerelove/

That's the website I am working on right now, I just started it... But I need help with the script... See, when you click on something in the menu, it doesn't open up on the right side like it's suppose to... how do I fix this?

HaganeNoKokoro
07-03-2005, 12:46 AM
I think you need to give your frames names, and set the target of the links in your left navigation frame to the name you give the main frame.

BeachSide
07-03-2005, 12:55 AM
Whoa... That needs some work!

First of all I would not recommend frames. What your doing with them is not what they were designed to do!

That said, if you must use them...

Think of frames as individual html pages. Meaning that your left frame needs to be an HTML page all unto itself as well as your right frame. Right now they are just snippets of code (at least the left frame is).

The main page also needs to be a seperate properly structured HTML page like this...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>austerelove</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="i.js"></script>
</head>

<frameset rows="*" cols="23%,*" framespacing="0" frameborder="NO" border="0">
<frame src="http://www.freewebs.com/austerelove/menu.html" name="leftFrame" scrolling="NO" noresize>
<frame src="http://www.freewebs.com/austerelove/main.html" name="mainFrame">
</frameset>
<noframes><body>
You do not support frames!
</body></noframes>
</html>


In the left menu frame there you sure do have a lot of JavaScript :eek: I would consider thinking about using another method.

With that said too the code should be more like


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="/i.js"></script>
<style type="text/css">
.menutitle{
cursor:pointer;
margin-bottom: 5px;
background-color:#ECECFF;
color:#000000;
width:140px;
padding:2px;
text-align:center;
font-weight:bold;
/*/*/border:1px solid #000000;/* */
}

.submenu{
margin-bottom: 0.5em;
}
</style>
<script type="text/javascript">

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

</script>
</head>

<body background="http://www.freewebs.com/austerelove/images/lightpurplebkg.jpg">
<img src="http://www.freewebs.com/austerelove/images/Corner.jpg">
<!-- Keep all menus within masterdiv-->
<div id="masterdiv">

<div class="menutitle" onclick="SwitchMenu('sub1')">Site Menu</div>

<span class="submenu" id="sub1">
- <a href="http://www.freewebs.com/austerelove/" target="mainFrame">Home</a><br>
- <a href="#" target="mainFrame">URL</a><br>
- <a href="#" target="mainFrame">URL</a><br>
- <a href="#" target="mainFrame">URL</a> </span>

<div class="menutitle" onclick="SwitchMenu('sub2')">Sub Menu</div>
<span class="submenu" id="sub2">
- <a href="#" target="mainFrame">URL</a><br>
- <a href="#" target="mainFrame">URL</a><br>
- <a href="#" target="mainFrame">URL</a>

</span>

<div class="menutitle" onclick="SwitchMenu('sub3')">Help Forum</div>
<span class="submenu" id="sub3">
- <a href="http://www.codingforums.com" target="mainFrame">Coding Forums</a><br>
</span>

<div class="menutitle" onclick="SwitchMenu('sub4')">Cool Links</div>

<span class="submenu" id="sub4">
- <a href="http://www.javascriptkit.com" target="mainFrame">JavaScript Kit</a><br>
- <a href="http://www.freewarejava.com" target="mainFrame">Freewarejava</a><br>
- <a href="http://www.cooltext.com" target="mainFrame">Cool Text</a><br>
- <a href="http://www.google.com" target="mainFrame">Google.com</a>

</span>

<img src="about.gif" onclick="SwitchMenu('sub5')"><br>
<span class="submenu" id="sub5">
- <a href="http://www.dynamicdrive.com/link.htm" target="mainFrame">Link to DD</a><br>
- <a href="http://www.dynamicdrive.com/recommendit/" target="mainFrame">Recommend Us</a><br>
- <a href="http://www.dynamicdrive.com/contact.htm" target="mainFrame">Email Us</a><br>

</span>

</div>

</body>
</html>


Wow there is a lot of errors in your markup, double body tags etc...

Really you should think about cleaning that stuff up there

Also if you use the menu code I supplied add this to your link tags

target="mainFrame"

It will tell it to load the links into the mainFrame