|
-
May 30th, 2004, 06:33 PM
#1
Thread Starter
Junior Member
Javascript works in Firefox & not in IE???
Hi all,
Im have a problem getting this code to work in IE, it works perfectly in Firefox. Any help much appricated.
Thanks JoePC
Code:
<html>
<head>
<title>DHTML & CSS for the WWW | Creating a Sliding Menu</title>
<script language="JavaScript"><!--
var open = 0;
var slideSpeed = 10;
var object = null;
function setMenu (objectID) {
object = document.getElementById(objectID);
if (open) { fX = -80; cX = 0; open = 0; }
else { fX = 0; cX = -80; open = 1; }
slideMenu(cX,fX);
}
function slideMenu (cX,fX) {
if (cX != fX) {
if (cX > fX) { cX -= slideSpeed; }
else { cX += slideSpeed; }
object.style.left = cX + 'px';
setTimeout('slideMenu(' + cX + ',' + fX + ')', 0);
}
return;
}
// -->
</script>
<style type="text/css"><!--
body {
margin-left: 30px
}
#mainMenu {
top: 0;
left: -80px
}
.menu {
position: fixed;
}
a:link {
color: red;
font: bold 12px "Trebuchet MS", Arial, Helvetica, Geneva, sans-serif
}
--></style>
</head>
<body>
<span id="mainMenu" class="menu">
<table width="100" border="0" frame="frame" cellspacing="0" cellpadding="5" bgcolor="#999999">
<tr>
<td align="right" bgcolor="#cccccc" width="80"><a href="#">Option 1</a></td>
<td rowspan="6" width="10">
<div align="left">
<a href="javascript:setMenu('mainMenu')" onFocus="if(this.blur)this.blur();"><img src="menuTab.gif" height="100" width="15" border="0" /></a></div>
</td>
</tr>
<tr>
<td align="right" width="80"><a href="#">Option 2</a></td>
</tr>
<tr>
<td align="right" bgcolor="#cccccc" width="80"><a href="#">Option 3</a></td>
</tr>
<tr>
<td align="right" width="80"><a href="#">Option 4</a></td>
</tr>
<tr>
<td align="right" bgcolor="#cccccc" width="80"><a href="#">Option 5</a></td>
</tr>
<tr>
<td align="right" width="80"><a href="#">Option 6</a></td>
</tr>
</table>
</span>
</body>
</html>
Thanks again.....
-
Jun 1st, 2004, 10:47 AM
#2
Frenzied Member
If it works in gecko, why change it ?
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Jun 1st, 2004, 10:58 AM
#3
I think it has to do with how getElementById is used....
Try looking at http://www.dynamicdrive.com .... they've got tons of this stuff, and all marked as what it will and will not work on.
TG
-
Jun 2nd, 2004, 02:31 AM
#4
Code:
href="java script:setMenu('mainMenu')"
This is dodgy. Not only should it be an onclick, but if it is a href then javascript: should be together.
fixed is not supported in IE.
Since you're using XHTML (the img tag is XHTML style) this must be all lowercase.
Code:
<script language="JavaScript"><!--
Along the same lines, you must use the type attribute (set it to "text/javascript") and must not use comments to hide the JS.
That's what I see for now. The last two ought not to affect any browser.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|