...

View Full Version : open a new window with a specific size



robin9000
09-28-2011, 05:30 PM
I have looked up on line and found what I thought should work but dose not seem to open a new widow of a specific size when I click on my image.

<script type="text/javascript">function openNewWindow()
{
window.open("http://www.microsoft.com", "_blank",
"height=340px width=240px");
}</script><img src="../../Images/photo_gallery/Models/ashly-model.jpg" alt="Model-Ashly" width="200" height="171" class="boarder" longdesc="../../Images/photo_gallery/Models/ashly-model.jpg" />

The above code is what I thought would work but dose not seem to when I try the page out. What am I doing wrong?

Thanks all.

VIPStephan
09-28-2011, 05:58 PM
If you do a proper search for “javascript window open” you will find hundreds of sources that show you the proper syntax. The first result I get is http://www.javascript-coder.com/window-popup/javascript-window-open.phtml and there a little further down the page is clearly stated how window size is applied.

StadriWebmaster
09-28-2011, 07:09 PM
Try this instead:

<a href="javascript:void(0);"
name="microsoft" title=" microsoft " id="microsoft"
onclick="window.open("http://www.microsoft.com";,"Ratting","width=340,height=240,0,status=0,");"><img src="../../Images/photo_gallery/Models/ashly-model.jpg" alt="Model-Ashly" width="200" height="171" border="0" /></a>

VIPStephan
09-28-2011, 09:09 PM
StadriWebmaster: Please, please, don’t annoy us with outdated code and bad practice.

For one, the name attribute is deprecated (except on form controls) and has been for at least ten years now. If at all you should use id instead. Likewise, the border attribute is deprecated and CSS should be used to style elements.

Secondly: What’s that javascript:void(0) crap in the anchor’s href doing? There is no “javascript” protocol and generally, if a link isn’t supposed to do anything, why write a link in the first place? You could use any element (and style it appropriately with CSS) – or make the link actually link the target so users would be able to get the content in case JS isn’t active or whatever.

StadriWebmaster
09-28-2011, 09:32 PM
StadriWebmaster: Please, please, don’t annoy us with outdated code and bad practice.

For one, the name attribute is deprecated (except on form controls) and has been for at least ten years now. If at all you should use id instead. Likewise, the border attribute is deprecated and CSS should be used to style elements.

Secondly: What’s that javascript:void(0) crap in the anchor’s href doing? There is no “javascript” protocol and generally, if a link isn’t supposed to do anything, why write a link in the first place? You could use any element (and style it appropriately with CSS) – or make the link actually link the target so users would be able to get the content in case JS isn’t active or whatever.

Whoa, sorry. I didn't know it was out of date or that there was anything wrong with it. I use it on many of my sites and it works like a charm.

VIPStephan
09-28-2011, 10:26 PM
Sorry, I may have been a little harsh. Yes, it may work but it’s outdated and bad practice nevertheless. If you want to go with time then read on unobtrusive javascript (http://en.wikipedia.org/wiki/Unobtrusive_JavaScript) and behavioral separation (http://www.alistapart.com/articles/behavioralseparation).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum