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 9 of 9
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question How do I get a link to open in a new window?

    I'm trying to get a link to open in a new window, but so far the best I could do is get it to open in a new tab by setting target="_blank" in the <a> tag. How can I get a link to open in a new browser window and also specify the length and width of the new window?

    Thanks in advance for any help.

  • #2
    Regular Coder
    Join Date
    Dec 2010
    Posts
    414
    Thanks
    22
    Thanked 55 Times in 55 Posts
    take a look at this.
    Pretty sure you have to use javascript to make it open in a new window and not a new tab
    http://www.htmlforums.com/client-sid...ab-137214.html

    Cheers

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,458
    Thanks
    0
    Thanked 632 Times in 622 Posts
    Even with JavaScript you can't guarantee where it will open. Also the size and location options you can specify for JavaScript are just suggestions that the browser can ignore.

    The only way to be certain that a page will open in a new window is when you are the one opening it - you right click on the link and select "new Window".
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you can use JavaScript to open a new window

  • #5
    New Coder
    Join Date
    Jul 2012
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    Even with JavaScript you can't guarantee where it will open. Also the size and location options you can specify for JavaScript are just suggestions that the browser can ignore.

    The only way to be certain that a page will open in a new window is when you are the one opening it - you right click on the link and select "new Window".
    While that may be true on the technical side, no user will want to manually open a new window.

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,471
    Thanks
    6
    Thanked 980 Times in 953 Posts
    Quote Originally Posted by The Noob Coder View Post
    While that may be true on the technical side, no user will want to manually open a new window.
    How do you know that?

    In fact, target="_blank" was removed from the HTML 4 specification because the tenor was that people shouldnít be forced a new window/tab but should be able to decide for themselves how they would open links. And I do know people who actually do this (you can also Shift-click a link to open a new window or Ctrl/Cmd-click to open a new tab).

  • #7
    New Coder
    Join Date
    Jul 2012
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    How do you know that?
    Good question. I guess I was just speaking for myself (and my boss). Personally, if a link says (or implies) that it will open in a new window, I don't want to have to do extra work to get it to do what it promises. But if that is not your view of it, no problem. We can agree to disagree.

  • #8
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,471
    Thanks
    6
    Thanked 980 Times in 953 Posts
    Thing is that most links don’t say that they are opening in a new window. Take Wikipedia for example. External links have an icon but it only says that this link will lead away from Wikipedia, it doesn’t say it opens in a new window. And (luckily, in my opinion) it’s up to the user to decide. I wouldn’t want every external link to open in a new window/tab (but this time I can only speak for myself either).

    I’m not saying that this couldn’t be useful at times but it’s not the norm for the average website.

  • #9
    New Coder
    Join Date
    Jul 2012
    Posts
    79
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    Iím not saying that this couldnít be useful at times but itís not the norm for the average website.
    You're absolutely right about that. I am just using it for a specific application. In my online store (where we sell t shirts) I have a link in all the shirt descriptions that links to a sizing chart. It just made more sense to have this pop up because the user would just take a single quick glance to figure out what size they want and not look at it anymore.


  •  

    Tags for this Thread

    Posting Permissions

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