alejandro52 Posted June 1, 2007 Share Posted June 1, 2007 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 https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/ Share on other sites More sharing options...
fenway Posted June 1, 2007 Share Posted June 1, 2007 The only thing that I can think of is that you need a unit for your top parameter (e.g. px). Link to comment https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-266256 Share on other sites More sharing options...
emehrkay Posted June 1, 2007 Share Posted June 1, 2007 kinda tough to read, do you indent? anyway, is currentStyle a js attribute that you can access? and do you have ids starting with numbers?(that wont validate) nah currentStyle is an ie only thing, that's your problem http://www.quirksmode.org/dom/getstyles.html Link to comment https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-266341 Share on other sites More sharing options...
nogray Posted June 1, 2007 Share Posted June 1, 2007 You can check out the NoGray JavaScript Library, it has a lot of the style functions you want (in the base.js), and you can get any current style in any browser using the getStyle() function http://www.nogray.com Link to comment https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-266383 Share on other sites More sharing options...
alejandro52 Posted June 1, 2007 Author Share Posted June 1, 2007 Thx a lot guys.i'll try it out. Link to comment https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-266447 Share on other sites More sharing options...
alejandro52 Posted June 2, 2007 Author Share Posted June 2, 2007 You can check out the NoGray JavaScript Library, it has a lot of the style functions you want (in the base.js), and you can get any current style in any browser using the getStyle() function http://www.nogray.com The getStyle doesn't work.In the support forums it says i need the IE_loader.js.Where I can find that? Link to comment https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-266743 Share on other sites More sharing options...
emehrkay Posted June 4, 2007 Share Posted June 4, 2007 if you want to use a js library, i suggest mootools mootools.net check out their docs and demos Link to comment https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-267544 Share on other sites More sharing options...
nogray Posted June 4, 2007 Share Posted June 4, 2007 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 https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-267719 Share on other sites More sharing options...
nogray Posted June 4, 2007 Share Posted June 4, 2007 P.S. I just updated the NoGray JS Library, please download the new files. Thank Link to comment https://forums.phpfreaks.com/topic/53834-firefox-wont-display-it-ie-will/#findComment-267736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.