Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Javascript working in IE9 not in IE7

    I have a jumpmenu that opens a shadowbox to show an image. It works fine in IE9, but in IE7 the shadowbox does not open and in the developer tools the error says "The value of the property 'MM_jumpMenu' is null or undefined, not a Function object". Being a noob I have no idea what the problem is.

    The coding in the <head> is;

    Code:
    <script type="text/javascript" src="shadowbox.js"></script>
    <script type="text/javascript">
    Shadowbox.init();
    </script>
    
    <script type="text/javascript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    if (selObj.selectedIndex == 0) return;
    Shadowbox.open({
    content: selObj.options[selObj.selectedIndex].value,
    player: 'img',
    });
    if (restore) selObj.selectedIndex=0;
    } function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>
    And in the <body> is;

    Code:
    <div id="apDiv2"> 
    <form name="form1" id="form1">
    <select name="Tema Demo" onchange="MM_jumpMenu('parent',this,0)">
    <option value="Select Campsite" selected="selected">Select Campsite</option>
    <option value="/images/stories/campsite_images/Site (1)/1.jpg">Site 1</option>
    <option value="/images/stories/campsite_images/Site (3)/3.jpg">Site 3</option>
    </select>
    </form>
    </div>
    There are more options than this but I reduced them down for convenience.
    Any help would be greatly appreciated.
    Many thanks,
    Keith.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    You have a bogus extra comma in there. It really should never be there, but apparently MSIE 9 is more "forgiving" than MSIE 7 is.

    The comma at the end of player: 'img', is bogus. player is the last property in the list, so it really shouldn't have a comma after it, ever.

    In the longer run, it's time to get rid of the crappy DrunkWalker code. You don't need that silly MM_jumpMenu thing at all.
    Code:
    function openShadowbox( sel )
    {
        if ( sel.selectedIndex != 0 )
        {
             Shadowbox.open(
                { content: sel.value;
                   player: 'img' } );
        }
    }
    and then
    Code:
    <select name="Tema Demo" onchange="openShadowbox(this);">
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much for that. The irony is that with the comma there it worked in IE9, firefox, chrome, opera and safari. It made me think it was a compatibility thing.
    I tried using the code you offered but that didn't work in IE7 or 9 (the only other one I tried was firefox and it did work in that). But to be honest I am just happy it worked at all.
    Thank you once again.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Now that utterly mystifies me. I could certainly see that the extra comma might not be the only reason it doesn't work in MSIE7. Maybe something to do with the ShadowBox code. But it makes no sense that just removing that comma would cause MSIE 9 to fail.

    You really made no other change, other than removing the comma???
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm sorry, I think I have caused a misunderstanding. Using the original coding that I posted and deleting the comma as you suggested, it now works in everything I have tested - firefox, opera, chrome, safari, and IE7 and 9. Using the code that you posted as a response (I am assuming I change the whole code between <!-- and //-->), it worked in firefox but not in either IE7 or 9 (I did not check the others).
    Sorry for the confusion and thank you once again.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Well, you also had that other function in there:
    Code:
    function MM_openBrWindow(theURL,winName,features) { //v2.0
        window.open(theURL,winName,features)
    }
    and you don't show any of your code using it, so I omitted it. But if other code not shown uses it, it would need to still be there.

    But other than that. I can't see any functional difference in the two codes. But of course I don't have ShadowBox to test it with, so I could well have a typo in there.

    But whatever. There's no real reason to use my code, so I'm glad that the simple fix worked.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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