Jump to content

firefox won't display it, ie will


alejandro52

Recommended Posts

I'm trying to create a dynamic menu but there are some dom elements that don't work with firefox. can someone show what dom elements i have to change to work for both?

Here is the code

<script LANGUAGE = "JAVASCRIPT">
function loading(){
var i;
var d;
for (i=1;i<8;i++){
var d=document.getElementById(i);
d.style.top=i*38;
}
}
window.onload = loading;

function dropdown(id){
var img=document.getElementById('img'+id);
var d_this = document.getElementById(id);
var sub_menu = document.getElementById('sub'+id);
if (img.alt=="down_arrow"){
	move_down(id,img,d_this,sub_menu);
}else if (img.alt=="up_arrow"){
move_up(id,img,d_this,sub_menu);
}
}


function move_up(id_others,img,d_this,sub_menu){
img.src="images/down_arrow.gif";
img.alt="down_arrow";
for(i=1;i<8;i++){
if ((i)!=id_others){
if((i)>id_others){
d=document.getElementById(i);
d.style.top=(i*38);
}
}
sub_menu.style.visibility='hidden';
}
}



function move_down(id_others,img,d_this,sub_menu){
var hei=parseInt(sub_menu.currentStyle.height);
var i;
img.src="images/up_arrow.gif";
img.alt="up_arrow";
for(i=1;i<8;i++){
var img_next=document.getElementById('img'+i);
var sub_next=document.getElementById('sub'+i);
if ((i)!=id_others){
	if(img_next!=null&&img_next.alt=="up_arrow"){dropdown(i)}
	if((i)>id_others){
	var d=document.getElementById(i);
	d.style.top=i*38+hei;	
	}
}
}
sub_menu.style.visibility='visible';
sub_menu.style.top=parseInt(d_this.currentStyle.height)+parseInt(d_this.currentStyle.top);
}

</script>

Link to comment
Share on other sites

I am sorry about the documentations, just updated the NoGray Library and didn't have time to update the docs.

 

Here is how you can use the getStyle function

 

I remove the IE loader file to speed up the JS library and reduce the number of files you'll need

 

Let's say I want to get the background color of a div tag with the ID "main_div" the code will be like the following

<html>
<head>
<!-- including the base.js from the NoGray JS Library -->
<script language="javascript" src="nogray_lib/base.js" type="text/javascript"></script>

<script language="javascript">
function ini_page(){
	// this function will set all the function of the NoGray library
	// to the object, you can add as many objects as you want
	// make_NoGray(object1[, object2, object3, ...])

	// the _obj function will return the object with the id
	// the same as document.getElementById()

	make_NoGray(_obj('main_div'));

	// the getStyle function will return the current style of the object
	// the style property must be in a valid JavaScript format
	// backgroundColor is good
	// background-color won't work
	// background won't work, must be a full property
	alert (_obj('main_div').getStyle("backgroundColor"));

}
</script>

</head>
<body onload="ini_page();">
<div id="main_div" style="background:#efefef;">Hello World</div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.