SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onload works with IE but not FF

    hello forum!

    can someone please, PLEASE, tell me why this combo works perfectly in IE and FF:

    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>

    echo <<<EOD
    <td width="45" height="65" class="{$class}" onclick="javascript:MM_openBrWindow('/schedule/schedule_this_day.php?day={$i}','','width=300,height=625');">
    EOD;

    and this combo seems to be working (I think) in IE, but is being totally ignored by FF?

    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>

    <BODY onLoad="javascript:MM_openBrWindow('/messaging/dummy_note.php?title=<?php echo $event_title; ?>&amp;date=<?php echo $event_date; ?>','','width=500,height=400');">
    </BODY>

    tried looking for the answer around here but I'm in way over my head, and it looks like this stuff can get really complicated.
    not asking for a solution - just want to know if the problem lies within what I put up here (I hope), or if it's something I'm doing elsewhere.
    MANY THANKS

  2. #2
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,234
    Mentioned
    47 Post(s)
    Tagged
    1 Thread(s)
    There are many many forbidden and wretched things in all versions of the code above... just so you know.

    My guess is that the second one has issues because it's got PHP in there, while the first has plain text. But I'm not sure, because what you posted is not what the browser sees.

    Could you do a View Source and post that? That's what the browser sees: your PHP will be HTML in the regular part of the page, and I'm curious to see what the PHP in the script tags become... PHP or HTML?
    Or, does the second version work if you put plain text in there instead of PHP?

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2009
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your gracious response Stomme poes.

    yea, it's a mess & now a real can of worms - more trouble than it's worth. I think I'll just make it an onclick, or drop it all together.

    as far as the passing of variables, even

    <BODY onLoad="javascript:MM_openBrWindow('/messaging/dummy_note.php','','width=500,height=400');"></BODY>

    did nothing at all - no popup.

    thanks again though! best regards,

    -mike

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    It may be that other things are clobbering the onload event.

    Move the script to the bottom of the page, just before the </body> tag.

    Code html4strict:
    <body>
    <!-- start html content -->
    ...
    <!-- end html content -->
    <script type="text/javascript">
    // javascript code here
    </script>
    </body>
    </html>

    Then for the javascript code, place the old onload code there.

    Code javascript:
    MM_openBrWindow('/messaging/dummy_note.php','','width=500,height=400');

    That will then be a lot more stable.

    If scripting still doesn't start, then it's likely that something else is causing a scripting error which stops all further scripting from occurring. A deeper look in to a test demo page may be appropriate.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •