SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    popup window opens in IE, not in Mozilla

    The following code works fine in IE but the popup window doesn't open in Mozilla 1.7.3 or Firefox 1.0

    <script language="JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_findObj(n, d) { //v4.0
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && document.getElementById) x=document.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }

    function popup_window() {
    window.open('http://www.learn2sail.com.au/popup.html', 'popup', 'width=600, height=400, menubar=yes, scrollbars=no, toolbar=no, location=no, resizable=no, top=10, left=50');
    }
    //-->
    </script><br>
    </head>

    <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" onLoad="MM_preloadImages('h6a.gif')" onLoad="popup_window()">
    ...

    I've turned off popup blockers and tried different Javascript scripts but no joy so far. Any suggestions?

    Regards from
    Ron
    Queensland, Australia

  2. #2
    SitePoint Zealot coothead's Avatar
    Join Date
    Jan 2005
    Location
    Chertsey, London, England
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there rshafran,

    Firefox will not allow you to take control away from the client.
    In other words, it will not allow pop-ups onload.

    coothead

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What errors do you get in the JavaScript console?

  4. #4
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I copied and pasted you code right into a file here, shut off FF & MOZ popup stoppers and IT WORKS JUST FINE..... there are not javascript errors in the console whatsoever.....however

    You do have two very minor mistakes there ....... first off you have a br tag after the ending script tag (before the ending head tag) no html allowed up there...... other minor issue: language="JavaScript" should be changed to this: type='text/javascript' ........ the language attribute is dead but the type should be declared with that tag

    besides that it works just fine

  5. #5
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Coothead - I didn't know that.

    Pepejeria - None, but I'm not sure I have figured out how to point the Javascript Console at the site properly. I fired up the site's index.html online in Mozilla then started up the Console but it gave me what appeared to be feedback about Mozilla code on my hard drive.

    DC Dalton - Thanks for your feedback. I still can't get popup window to display in my Mozilla though I'm cheered you can; and strangely enough if I remove the <br> from end of /head section the popup won't display in IE but other than that everything's great. (p.s.I think you'll like winter in SE FLA better than NE PA)

  6. #6
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know Ill like FLA better than "hillbilly land" or as the locals say up here "It aint the end of the world but you can see it from here"

    Anyways ........ that br tag after the scripts is TOTALLY invalid .... html formatting tags are not allowed in the head .......... strange that IE screws up when you take it out ....... seems there MIGHT be an issue we have overlooked!

  7. #7
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just noticed something ......... you have TWO onloads in your body tag and your window opening code was a touch , ehhh, twitchy..

    Try this code and see what happens:

    Code:
    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <script type="text/javascript">
    <!--
    function openPopup()	 {
     window.open("http://www.learn2sail.com.au/popup.html","popup","toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,resizable=0,width=600,height=400,left=50,top=10");
    	}
    //-->
    </script><br>
    </head>
    
    <body onload="openPopup();">
    </body>
    </html>

    and to do mulitple javascript calls in one event you do this

    <body onload="functionOne();FunctionTwo();">

  8. #8
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DC Dalton - thanks for the reply and the code tweak. I've uploaded the new code though still no joy seeing it with Mozilla, but not the end of the world.

    Cheers,


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
  •