SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member indigo_child's Avatar
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem creating popup window that works

    I created a popup window for my web page but the popup window doesn't appear in IE 6.0. But it appears in Mozilla Firefox 1.5. I want it to work in IE. I've turn off the popup blocker but it still doesn't work. Here's the code:

    Code:
    <script language="javascript" type="text/javascript">
    <!--
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.availWidth)?Math.floor(Math.random()*(screen.availWidth-w)):50;TopPosition=(screen.availHeight)?Math.floor(Math.random()*((screen.availHeight-h)-75)):50;}
    if(pos=="center"){LeftPosition=(screen.availWidth)?(screen.availWidth-w)/2:50;TopPosition=(screen.availHeight)?(screen.availHeight-h)/2:50;}
    if(pos=="default"){LeftPosition=50;TopPosition=50}
    else if((pos!="center" && pos!="random" && pos!="default") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
    win=window.open(mypage,myname,settings);
    if(win.focus){win.focus();}}
    function CloseNewWin(){if(win!=null && win.open)win.close()}
    window.onfocus=CloseNewWin;
    // -->
    </script>
    and for the link:

    Code:
    <a href="report_siteinstall&Comm.htm" onclick="NewWindow(this.href,'report_siteinstall&Comm.htm','213','32','yes','center');return false">Site Installation & Commission</a>

  2. #2
    SitePoint Enthusiast Tygatur's Avatar
    Join Date
    Apr 2006
    Location
    Germany
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all there are 2 spaces in your code (but maybe just a matter of copy&paste into this forum)

    (screen.avai lHeight-h)
    ,toolbar=n o,

    Then the URI is not valid.
    You can't use an ampersand in your URL if you didn't use a questionmark somewhere before it.

    the left-property is not an Int. There are no half pixels.

    But the lethal mistake seems to be the second window.open() parameter.
    It's not possible to use any other characters except numbers und letters for the name of the window.
    to code or not to code ?
    that's too much of a question for a signature.

  3. #3
    SitePoint Member indigo_child's Avatar
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah... it's bcoz of the copy+paste. But I got this code from a code generator page. It' s not mine. I just changed a few things. The big question here is why does work in my Mozilla Firefox 1.5 but not IE 6.0?


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
  •