Results 1 to 7 of 7

Thread: quick html question - new window fixed size.

  1. #1
    Join Date
    Jul 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face quick html question - new window fixed size.

    hi ive got a link and it opens in new window. Now what i want to do is once the user clicks on the link the new window opens but on a specific size... how can i do this? i could not find a script on dynamic drive. If anybody can help then it would be much appreciated.

    Thanks in advance!

  2. #2
    Join Date
    Oct 2006
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hehe, i got this script workin to open new windows for a sad excuse for a windows widget kinda thing lmao but it does what you lookin for:

    HTML Code:
    <head>
    
    <script LANGUAGE="javascript">
    	<!-- defines size of window -->
    	function ScreenSize(w,h){
    	window.resizeTo(w,h);
    	}
    </script>
    
    </head>
    
    <body onload="javascript:void window.ScreenSize(205,233); ">
       BODY CONTENT
    </body>
    after thought.....u mentioned 'fixed'.....put this in yer links and they won't be able to resize the window

    HTML Code:
    <a href="javascript:void window.open('LINK GOES HERE','','resizable=no,scrollbars=yes,menubar=no,toolbar=no,location=no');">LINK NAME GOES HERE</a>
    modify the other parameters as nessesary
    Last edited by the-disturbed; 10-19-2006 at 03:52 AM.

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by the-disturbed
    Code:
    function ScreenSize(w,h){
    	window.resizeTo(w,h);
    }
    The OP should be aware that this may not work: it certainly doesn't have a chance, here.

    <body onload="javascript:void window.ScreenSize(205,233); ">
    The "javascript:" portion is just a label, and is pointless. MSIE does make it meaningful, but it's still unnecessary unless VBScript was in use (and it should never be on the Web). The void operator is similarly extrenuous: the called function will return undefined, which is precisely what the void operator evaluates to. Finally, the ScreenSize function is global: it does not need to be accessed as a property.

    after thought.....u mentioned 'fixed'.....put this in yer links and they won't be able to resize the window
    There should never be a reason to restrict resizing. If the window size is appropriate, then the user probably won't even try. However, if it's not, then the user might have to. At a minimum, if the feature string is present when calling the open method, then it should at least contain 'resizable,scrollbars'.

    Mike

  4. #4
    Join Date
    Oct 2006
    Posts
    75
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    why exactly won't it work, it works fine for me, in IE at least, dunno bout FF

  5. #5
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Can be done much easier:

    <a href="#" onClick="MyWindow=window.open('yourname.html','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,heigh t=350'); return false;">text</a>

  6. #6
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by the-disturbed
    why exactly won't it work ...
    Because it can be disabled (and is, here).

    I have no desire for anyone to resize any window I have open. I know what's best for me. The same cannot be said by some random Web developer.

    Quote Originally Posted by chechu
    <a href="#" ...
    That is a bad start. Links should be links.

    HTML Code:
    <a href="<uri>" target="_blank" onclick="window.open(this.href, this.target); return false;">...</a>
    Still, opening new windows is generally a bad idea. If the user wants a new window, they can manage that themselves. If the user doesn't, it's a lot harder for them to override an author that wants to try and force it.

    Mike

  7. #7
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wink

    While it may be true that most times you shouldn't need to create a new window, iti s best used on links that are outside of your website or when you want to create a form for users to fill out. when they are done they can close the window and return beck to the page they were previously viewing. new windows with specific dimensions are not bad in the right context.

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
  •