cracking up with script error in internet explorer

Discussion in 'Coding Help' started by larfie, Sep 8, 2011.

  1. larfie

    larfie New Member

    Hi Guys, great site.

    I'm hoping someone can help me out with this as I'm tearing my hair out. I keep getting a script error for my site mbfiresafety.com when opened in internet explorer. I've spent days altering code and I can't figure out where I'm going wrong. I'd really appreciate it if someone could help me out.

    This is the error I'm getting;
    Unable to get value of the property 'getElementsByTagName': object is null or undefined
    index.php, line 20 character 2.... which is this line: var sfEls1 = document.getElementById("catmenu").getElementsByTagName("li");

    I don't think that the error is in the css, I think it's got to do with IE interpreting the jscript. I'm not sure though. I used to script when I was a kid and I'm trying to pick it up as I go along now.

    Thanks for your help
     
  2. php.allstar

    php.allstar New Member

    Hi, that means that the "catmenu" item does not exist...

    There is no item in the document that has the id of catmenu
     
  3. larfie

    larfie New Member

    Thanks for the reply. The catmenu item is in the css stylesheet;



    #catmenu{
    width:1000px;
    margin:5px 0px 0px 0px;
    padding: 0px 0px;
    float:left;
    height:35px;
    font-size:13px;

    }
    #catmenu ul{
    float: left;
    list-style: none;
    margin: 0px;
    padding: 0px;
    }
    #catmenu li{
    float: left;
    list-style: none;
    margin: 0px;
    padding: 0px;
    text-shadow:1px 1px 0px #EFECE5;
    }
    #catmenu li a, #catmenu li a:link, #catmenu li a:visited{
    color: #5F5F5F;
    display: block;
    padding: 0px 10px ;
    line-height:35px;






    }
    #catmenu li a:hover, #catmenu li a:active{
    color: #000;
    display: block;
    line-height:35px;
    background:url (images/cmenua.png) bottom center no-repeat;
    }
    #catmenu li li a, #catmenu li li a:link, #catmenu li li a:visited{
    background: #EFECE5;
    border-bottom: 1px solid #fff;
    color: #5F5F5F;
    float: none;
    margin: 0px;
    line-height:35px;
    width: 150px;
    }
    #catmenu li li a:hover, #catmenu li li a:active{
    background: #EFECE5;
    color: #000;
    float: none;
    line-height:35px;
    margin: 0px;
    width: 150px;


    }
    #catmenu li ul
    {
    height: auto;
    left: -999em;
    margin: 0px;


    position: relative;
    background:#fff;
    width: 170px;
    z-index: 1;
    overflow: visible !important;
    }
    #catmenu li li
    {
    }
    #catmenu li ul a
    {
    width: 140px;
    }
    #catmenu li ul a:hover, #catmenu li ul a:active
    {
    overflow: visible !important;
    }
    #catmenu li ul ul
    {
    margin: -36px 0 0 170px;
    }
    #catmenu li:hover ul ul, #catmenu li:hover ul ul ul,
    #catmenu li.sfhover1 ul ul, #catmenu li.sfhover1 ul ul ul
    {
    left: -999em;
    }
    #catmenu li:hover ul, #catmenu li li:hover ul,
    #catmenu li li li:hover ul, #catmenu li.sfhover1 ul,
    #catmenu li li.sfhover1 ul, #catmenu li li li.sfhover1 ul
    {
    left: auto;
    }
    #catmenu li:hover, #catmenu li.sfhover1
    {
    position: static;
    }



    Does it mean that I need to reference it more specifically? If so, then how do I do this?

    This is only a problem with IE. The site looks perfect in chrome, firefox and safari
     
  4. php.allstar

    php.allstar New Member

    Hi,

    The stylesheet only applies styles to an element.

    You will need to create an element with the id="catmenu" somewhere in your html code. I presume this will be the ul tag that contains your li items
     
  5. larfie

    larfie New Member

    It's in php which I am totally unfamiliar with. The script is as follows;

    <div id='topbar'>
    <?php wp_nav_menu( array( 'container_id' => 'catmenu', 'fallback_cb'=> '','theme_location' => 'primary' ) ); ?>
    </div>

    I've tried changing values around but to no avail. Any idea's?

    Also on a side note could you recommend a good php book?
     
  6. php.allstar

    php.allstar New Member

    Hi,

    The wp_nav_menu is not coming through in your code.

    When I looked at your source code I see

    <div id='topbar'> </div>

    No mention of your menu in there.

    This leads me to believe that you have not set up your menu properly in wordpress. Can you verify that you have set up a menu in worpdress in the "Primary Navigation" slot?

    It's in Wordpress Admin > Appearance > Menus

    The best PHP book I've read is "PHP In Action" ISBN: 1-932394-75-3

    Thanks,
    Simon
     

Share This Page