Results 1 to 3 of 3

Thread: getElementById return null in FF

  1. #1
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy getElementById return null in FF

    hi all,
    i create a menu by using js and html it works greate in İE but in FF it's suxx this is my all code.
    HTML Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <style>
    .AltMenu
    {
    	cursor:pointer;
    	display: block;
    	border: 1px solid black;
    	padding: 2px 5px 2px 10px;
    	text-decoration: none;
    	font-weight: 900;
    	color: #0000C0;
    	border-bottom: none;
    	font-family: Verdana;
    	font-size: 8pt;
    	background-image:url(images/Black.gif);
    	background-repeat:no-repeat;
    	background-position:left center;
    }
    .MainMenu
    {
    	cursor:pointer;
    	width: 100px;
    	border: 1px solid black;
    	background: #FFFFEE;
    	padding: 2px 5px 2px 5px;
    	font-weight: 900;
    	color: Gray;
    	font-family: Verdana;
    	font-size: 8pt;
    }
    
    </style>
    <title>t</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    var ExCell="";
    function SwichMenu(xName)
    {
    	if (ExCell!="") ExCell.innerHTML = "";
    	if (ExCell!=document.getElementById(""+xName+"_")) document.getElementById(""+xName+"_").innerHTML = document.getElementById(""+xName+"").innerHTML;
    	if (ExCell==document.getElementById(""+xName+"_")) ExCell = "";
    	else ExCell = document.getElementById(""+xName+"_");
    }
    </script>
    </head>
    
    <body>
    			<div  id='-1'><table>
    <tr><td name='6'  class='MainMenu'  onClick='SwichMenu(this.name);'   nowrap>Bilgilerim</td></tr><tr><td name='TempMenu' id='6_'></td></tr>
    <tr><td name='4'  class='MainMenu'  onClick='SwichMenu(this.name);'   nowrap>Gönderi</td></tr><tr><td name='TempMenu' id='4_'></td></tr>
    <tr><td name='1'  class='MainMenu'  onClick='SwichMenu(this.name);'   nowrap>Adres Defteri</td></tr><tr><td name='TempMenu' id='1_'></td></tr>
    </table></div>
    <div  style='visibility:hidden'  id='1'><table>
    <tr><td name='2'  class='AltMenu'  onClick='#'   nowrap>Yeni Kayıt</td></tr><tr><td name='TempMenu' id='2_'></td></tr>
    <tr><td name='3'  class='AltMenu'  onClick='#";'   nowrap>Kayıt Düzenleme</td></tr><tr><td name='TempMenu' id='3_'></td></tr>
    </table></div>
    <div  style='visibility:hidden'  id='4'><table>
    <tr><td name='5'  class='AltMenu'  onClick='#";'   nowrap>Gönderi Hazırla</td></tr><tr><td name='TempMenu' id='5_'></td></tr>
    </table></div>
    <div  style='visibility:hidden'  id='6'><table>
    <tr><td name='7'  class='AltMenu'  onClick='#";'   nowrap>Çıkış Adresleri Ekle</td></tr><tr><td name='TempMenu' id='7_'></td></tr>
    <tr><td name='9'  class='AltMenu'  onClick='#";'   nowrap>Çıkış Adresleri Düzenle</td></tr><tr><td name='TempMenu' id='9_'></td></tr>
    <tr><td name='11'  class='AltMenu'  onClick='#";'   nowrap>Favori Adreslerimi Düzenle</td></tr><tr><td name='TempMenu' id='11_'></td></tr>
    </table></div>
    
    </body>
    </html>
    i try using div but didn't work too.
    <tr><td name='TempMenu' id='11_'></td></tr> replace it by this <tr><td><div name='TempMenu' id='11_'></div></td></tr>
    thanks....

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by onurtpl
    i create a menu by using js and html it works greate in İE but in FF it's suxx this is my all code.
    Your markup is broken. Firefox can hardly be blamed for that.

    <html>
    HTML documents should begin with a document type declaration. There is little reason now for using anything other than a Strict DOCTYPE.

    <style>
    The type attribute is required for style elements:

    HTML Code:
    <style type="text/css">
    display: block;
    Applying the block value to table cells may produce very different behaviour when comparing IE to other, better browsers. IE's CSS support is simplistic and it considers many box types to be block, when in fact they should be something else like table-cell or table-row-group, for example. Browsers that actually understand the difference (like Firefox and Opera) will do as you ask and alter how they render the element, whilst IE will continue to do something much less sensible.

    font-family: Verdana;
    font-size: 8pt;
    Verdana should be avoided, especially if one intends to reduce the font size, and font sizes shouldn't be specified in either pixel or point units. See a recent post in the thread, Fonts (PC vs MAC) - what's your advice? and my follow-up to it.

    background-image:url(images/Black.gif);
    You specify a background image, but no background colour. This could make the foreground text almost impossible to read if the image isn't displayed.

    var ExCell="";
    It seems from the remaining code that the variable, ExCell, is a reference to a Node within the document. It makes little sense to represent the absense of a reference with an empty string. Use the null value.

    <div id='-1'>
    The value, -1, is not of the ID type, and is illegal. An id attribute value must start with a letter ([a-zA-Z]), and followed by any number of letters, numbers ([0-9]), underscores (_), hyphens (-), colons (:&#41;, and periods (.).

    <td name='6'
    Table cells do not have name attributes.

    <td name='2' class='AltMenu' onClick='#' nowrap>
    That seems to be a rather pointless onclick attribute value, and would throw an exception if executed as script code. The nowrap attribute is deprecated in favour of CSS.

    I'm sorry, but I would seriously suggest that you dump the lot and find an existing menu system that suits your needs. There is certainly no value in trying to fix that as it would need to be completely rewritten.

    Mike

  3. #3
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    mwinter thanks for your advices.
    "Table cells do not have name attributes." is the solition of my problem.
    <td name='6' onclick='alert(this.name);'... this code alert "undefined".
    And you're rigth about there is a lot of menu but i create this menu by Asp.Net page dinamicly. I get menu structer from a table... so is not to hard and it's easist way i found...
    thank you again...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •