Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    66
    Thanks
    5
    Thanked 2 Times in 2 Posts

    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

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    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.

  • #3
    New Coder StadriWebmaster's Avatar
    Join Date
    Aug 2011
    Location
    NY
    Posts
    42
    Thanks
    4
    Thanked 2 Times in 2 Posts
    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>

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    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.

  • #5
    New Coder StadriWebmaster's Avatar
    Join Date
    Aug 2011
    Location
    NY
    Posts
    42
    Thanks
    4
    Thanked 2 Times in 2 Posts
    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.

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •