Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-28-2011, 04:30 PM   PM User | #1
robin9000
New Coder

 
Join Date: Mar 2009
Location: Canada
Posts: 60
Thanks: 5
Thanked 2 Times in 2 Posts
robin9000 has a little shameless behaviour in the past
Question open a new window with a specific size

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.
__________________
My web site can be view here
http://robinsden.com
robin9000 is offline   Reply With Quote
Old 09-28-2011, 04:58 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,579
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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/wind...dow-open.phtml and there a little further down the page is clearly stated how window size is applied.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 09-28-2011, 06:09 PM   PM User | #3
StadriWebmaster
New Coder

 
Join Date: Aug 2011
Location: NY
Posts: 37
Thanks: 3
Thanked 2 Times in 2 Posts
StadriWebmaster is an unknown quantity at this point
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>
StadriWebmaster is offline   Reply With Quote
Old 09-28-2011, 08:09 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,579
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 09-28-2011, 08:32 PM   PM User | #5
StadriWebmaster
New Coder

 
Join Date: Aug 2011
Location: NY
Posts: 37
Thanks: 3
Thanked 2 Times in 2 Posts
StadriWebmaster is an unknown quantity at this point
Quote:
Originally Posted by VIPStephan View Post
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.
StadriWebmaster is offline   Reply With Quote
Old 09-28-2011, 09:26 PM   PM User | #6
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,579
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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 and behavioral separation.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:13 AM.


Advertisement
Log in to turn off these ads.