Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: open new pop up

  1. #1
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default open new pop up

    Is this older code still correct for a pop-up?
    I have "resize=no" down but it's letting me resize it.

    I'm not an expert. I copied this from somewhere long ago.

    Code:
    <script type="text/javascript">
    <!--
    function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
      if(window.screen)if(isCenter)if(isCenter=="true"){
        var myLeft =  (screen.width-myWidth-50)/2;
        var myTop = (screen.height-myHeight-50)/2;
        features+=(features!='')?',':'';
        features+=',left='+myLeft+',top='+myTop;
      }
      window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
    }
    
    //-->
    </script>
    Code:
    <a href="#" onClick="OpenBrWindow('pop.html','','toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=no','634','658','true');">Pop Up.</a>
    THANKS.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The proper specification for a new window that cannot be resized is:

    resizable=0

    Or, just omit resizable from the specification. However, many browsers will no longer allow a new window that isn't resizable. It's an accessibility issue.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    questions (08-09-2008)

  4. #3
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    THANKS!

    Does the rest of it look correct?
    Should all the "no" be "0"?

  5. #4
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Should all the "no" be "0"?
    The rest should be fine with "no".
    - Mike

  6. The Following User Says Thank You to mburt For This Useful Post:

    questions (08-09-2008)

  7. #5
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    And yes, you are right, I cannot control the resize, even with 0, it still let's you resize.

    Thanks.

  8. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Yeah I'm pretty sure Firefox doesn't let you control the "resize" attribute, but IE might. I'm not sure.
    - Mike

  9. #7
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    I think this is a bug on FF3, can't test on FF2 if this problem is reproducible. Tested with a simple call and resizable seems to take no effect:
    Code:
    <a href="#" onclick='window.open("http://www.google.com/",
    "mywin", "width=500,height=300,menubar=no,location=no,resizable=no,scrollbars=no,status=no");return false;'>Test</a>
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  10. #8
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Or maybe it is intended by Firefox. If the user can control the "resize" attribute, users may get annoyed by it. A website shouldn't be dependent on whether the window can resize or not.
    - Mike

  11. #9
    Join Date
    Jan 2008
    Location
    Los Angeles
    Posts
    97
    Thanks
    31
    Thanked 2 Times in 2 Posts

    Default

    Quote Originally Posted by mburt View Post
    Or maybe it is intended by Firefox. If the user can control the "resize" attribute, users may get annoyed by it. A website shouldn't be dependent on whether the window can resize or not.
    Yeah, on FF3. It's fine if someone resizes. I think they'd only do it by mistake. I'm just trying to pop up a detail of a webpage or a zoom into an image.

  12. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In the specification section of the window.open() method, no and 0 are equivalent. In fact, if you specify any valid specification in the specification section of window.open, anything that you omit is considered as 0/no or default.

    So let's break it down. You can do:

    Code:
    window.open('some.htm');
    That's at the discretion of the browser, but at the very least should be a new tab, unless the page has a base href of '_self', or all pop ups are blocked.

    Now:

    Code:
    window.open('some.htm', '_blank');
    we've designated a target. What you designate has consequences. With '_blank', it should be a unique new window, not a tab unless browser settings override that.

    Finally, we may add specifications:

    Code:
    window.open('some.htm', '_blank', 'width=400, height=350');
    The moment you add any specification, the browser almost has to open a new window. And all specifications not mentioned will be either 0/no/false, or if they don't qualify as boolean (true/false), they will be the default for that browser. And, as I was saying, some browsers will not allow false for things like:

    status
    scrollbars
    resizable

    If you don't have any specifications, a window.open method will usually open a normal window, or tab. If you have specifications, they will be followed first as far as the rules governing specifications go, then ultimately as far as the user's browser will allow.

    That's not to mention pop up blockers, which if set to their highest setting will block all new windows. It is because of this last fact that folks often prefer AJAX and/or lightbox type scripts. Those are generally only 'blocked' if the user has javascript disabled.
    Last edited by jscheuer1; 08-09-2008 at 03:28 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  13. The Following User Says Thank You to jscheuer1 For This Useful Post:

    questions (08-09-2008)

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
  •