...

View Full Version : I think this is an HTML problem body onload not working on Firefox



musher
01-20-2005, 09:59 PM
This page loads fine using IE, but not Firefox.
looks like the "body onload" is not running when I open it in firefox. (I don't think this is a java problem, but may be).
Div id company is displayed.
Div id products should but is not.
Div id Articles is not displayed.

Any one have any ideas, have searched for about an hour and found nothing.

PS. I did pull out the CSS link.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>

<script language="javascript" type="text/javascript">
function showsubmenu() {
document.all.Products.style.display ='block';
}
</script>
</head>
<body onload="showsubmenu()">
<DIV CLASS="menu">
<ul>
<li class='menu'><a class='menu' href='http://jimm/sweetlix/index.php'>Home</a></li>
<li class='menu'><a class='menu' href='http://jimm/sweetlix/company/index.php'>Company Info</a></li>
<div id="Company" style="display: block;">
<ul class="submenu">
<li class='submenu'><a class='submenu' href='http://jimm/sweetlix/'>Company Directory</a></li>
<li class='submenu'><a class='submenu' href='http://jimm/sweetlix/company/#.php'>Sales Territory Map</a></li>
</ul>
</div>
<li class='menu'><a class='menu' href='http://jimm/sweetlix/dealer/index.php'>Dealer Locator</a></li>
<li class='menu'><a class='menu' href='http://jimm/sweetlix/products/index.php'>Products</a></li>
<div id="Products" style="display: none;">
<ul class="submenu">
<li class='submenu'><a class='submenu' href='http://jimm/sweetlix/products/#.php'>Beef Cattle</a></li>
<li class='submenu'><a CLASS='submenu' href='http://jimm/sweetlix/products/#.php'>Dairy Cattle</a></li>
<li class='submenu'><a CLASS='submenu' href='http://jimm/sweetlix/products/#.php'>Horses</a></li>
<li class='submenu'><a CLASS='submenu' href='http://jimm/sweetlix/products/#.php'>Goats</a></li>
<li class='submenu'><a CLASS='submenu' href='http://jimm/sweetlix/products/#.php'>Sheep</a></li>
<li class='submenu'><a class='submenu' href='http://jimm/sweetlix/products/#.php'>Wildlife</a></li>
</ul>
</div>
<li class='menu'><a class='menu' href='http://jimm/sweetlix/articles/index.php'>Articles</a></li>
<div id="Articles" style="display: none;">
<ul class="submenu">
<li class='submenu'><a class='submenu' href='http://jimm/sweetlix/articles/#.php'>Cattle</a></li>
<li class='submenu'><a CLASS='submenu' href='http://jimm/sweetlix/articles/#.php'>Goats</a></li>
<li class='submenu'><a CLASS='submenu' href='http://jimm/sweetlix/articles/#.php'>Horses</a></li>
<li class='submenu'><a CLASS='submenu' href='http://jimm/sweetlix/articles/#.php'>Sheep</a></li>
<li class='submenu'><a class='submenu' href='http://jimm/sweetlix/articles/#.php'>Forages</a></li>
</ul>
</div>
<li class='menu'><a class='menu' href='http://jimm/sweetlix/contact/index.php'>Contact</a></li>
</ul>
</DIV>
</body>
</html>

Badman3k
01-20-2005, 10:20 PM
This is a JavaScript problem. Firefox doesn't recognise:


document.all.....


You have to use document.getElementById(".....") in order for it to work.
I presume everything but the menu works.

Hope this helps

Puffin the Erb
01-20-2005, 10:20 PM
This line is for Opera, IE and Konqueror only:

document.all.Products.style.display ='block';

This works with the above browsers and Gecko-based browsers like Netscape and Firefox:

document.getElementById('Products').style.display ='block';

Just replace the first with the second line.

HTH

JamieR
01-20-2005, 10:20 PM
Div id company is displayed.
Div id products should but is not.
Div id Articles is not displayed.

PS. I did pull out the CSS link.



I thought to use <div id="whatever></div> with CSS to pull the CSS attributes for "whatever" out of the css file and display it :D

musher
01-20-2005, 11:02 PM
Hey thanks guys
The document.getElementById fixed the problem, gosh another new thing learned today (brain is hurting again) :eek:





Originally Posted by musher
Div id company is displayed.
Div id products should but is not.
Div id Articles is not displayed.

PS. I did pull out the CSS link.

Originally Posted by weazel
I thought to use <div id="whatever></div> with CSS to pull the CSS attributes for "whatever" out of the css file and display it

Jamie
I pulled out the linked CSS file so most of the styling was missing, Just didn't want some one to question why I had a bunch of classes in my code and no CSS to go along with it. Each of my Divs does have an "ID" and a style="display: block;" to initialy hide them.



PS...... when u do a quote how do you get the (Originally Posted by Name) in there, i've been doing it by hand is there an automatic way to do this. :confused:

JamieR
01-20-2005, 11:20 PM
PS...... when u do a quote how do you get the (Originally Posted by Name) in there, i've been doing it by hand is there an automatic way to do this. :confused:

When you click on quote the previous post you are quoting on will be in the form body where you are typing your reply. To keep the "Originally Posted by.." you just need to keep the [1QUOTE=musher]the post here[/QUOTE]
Then type your post underneath.
I put the 1 in the opening quote tag otherwise VBulliten will parse it as a quote.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum