View Full Version : 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!
the-disturbed
10-19-2006, 03:38 AM
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:
<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
<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
mwinter
10-19-2006, 01:32 PM
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
the-disturbed
10-20-2006, 09:19 PM
why exactly won't it work, it works fine for me, in IE at least, dunno bout FF
chechu
11-01-2006, 04:29 PM
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,height=350'); return false;">text</a>
mwinter
11-01-2006, 05:45 PM
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.
<a href="#" ...
That is a bad start. Links should be links.
<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
Liderien
03-21-2012, 02:03 PM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.