Welcome to WebmasterWorld Guest from 54.196.244.245

Forum Moderators: open

Message Too Old, No Replies

What's the javascript for target=" blank"?

     
7:38 pm on May 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 25, 2003
posts:2527
votes: 0


Using this script in the head for processing ad links on the page:

<script type="text/javascript"> function clickTrack() { window.location="http://www.example.com" } </script>

the ads are surrounded by:

<span onmouseover="this.style.cursor='pointer'" onclick="clickTrack(); return false;" onMouseDown="clickTrack(); return false;">

How do I make that open in a new window?

Thanks
Mike
8:21 pm on May 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 16, 2007
posts:846
votes: 0


window.open('http://www.example.com','_blank')
12:06 am on May 2, 2010 (gmt 0)

Preferred Member

5+ Year Member

joined:May 29, 2007
posts: 578
votes: 0


Jakob Nielsen's Alertbox, May 30, 1999:
The Top Ten Web Design Mistakes of 1999
[useit.com]
2. Opening New Browser Windows
Opening up new browser windows is like a vacuum cleaner sales person who starts a visit by emptying an ash tray on the customer's carpet. Don't pollute my screen with any more windows, thanks (particularly since current operating systems have miserable window management). If I want a new window, I will open it myself!

Designers open new browser windows on the theory that it keeps users on their site. But even disregarding the user-hostile message implied in taking over the user's machine, the strategy is self-defeating since it disables the Back button which is the normal way users return to previous sites. Users often don't notice that a new window has opened, especially if they are using a small monitor where the windows are maximized to fill up the screen. So a user who tries to return to the origin will be confused by a grayed out Backbutton.
10:19 am on May 3, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 25, 2003
posts:2527
votes: 0


I totally agree with the sentiment, lavazza, but in this case, the user will be provide four possible providers for the service they have search for on our site. They will most likely go through the first provider's site considerably before deciding they are not suitable and wish to return to our website to try the other three in the same way. "Back" buttons, I did not feel, would be an easy way for them to do this. Opening each service provider in a new window seemed the best option for the user to me.
8:39 pm on May 3, 2010 (gmt 0)

Preferred Member

5+ Year Member

joined:May 29, 2007
posts: 578
votes: 0


Before implementing your intended approach, I suggest you test the idea by surveying a cross-section of users

You might be surprised, especially if they are using a variety of media and/or platforms

Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network.
Tim Berners-Lee [w3.org]
7:35 am on May 10, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member themadscientist is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 14, 2008
posts:2910
votes: 62


Don't pollute my screen with any more windows, thanks

Learn to use the tabbed browsing that's present in all major browsers. Thanks!

It's actually starting to annoy me when people DON'T open links in a new window, especially if they run a directory I might want to click more than one link from... Two or 3 pages into a site they link to is way more 'backs' than I want to click as a user. I would rather just close the window (AKA tab in 2010).
7:46 am on May 10, 2010 (gmt 0)

Preferred Member

5+ Year Member

joined:May 29, 2007
posts: 578
votes: 0


It's actually starting to annoy me when people DON'T open links in a new window, especially if they run a directory I might want to click more than one link from
Then use a combination of mouse (or similar input device) and UA (e.g browser) that has 'open in a new tab' as the default action for one of the buttons
8:52 am on May 10, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member themadscientist is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 14, 2008
posts:2910
votes: 62


You're citing a source from over a decade ago and the Internet is not stagnant much as it seems some would like to think what once applied should always apply... They didn't even have tabbed browsing then.

(particularly since current operating systems have miserable window management)

Not even close to true today.

Google's gone so far as to convert their results to AJAX and they're already discontinuing support for IE 6... The article you're referring to precedes even IE 5, and if people really don't like it every major browser has a pop-up blocker installed. I think it's time to move past the 1999 idea of the Internet personally.

@ Internetheaven, I think you would be silly to NOT open a new window for people if it makes the overall experience better, and keeps them from having to overuse the back button to return to your site and follow another link, because the Internet is definitely growing up, and most of the people who don't understand how to set a browser to open a new window in a new tab have kids who understand how to set a browser to open a new window in a new tab, and if they don't they probably have a friend who knows, and if it's something they really don't like they'll complain about it and learn how and may even realize pop-ups aren't such a bad thing any more after all.

I used to despise pop-ups, then they invented tabbed browsing and I think they're cool and useful, but don't get me started on pop-unders!
12:59 pm on May 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:May 6, 2008
posts:2011
votes: 0


Before you all start jumping on the OP for opening a new browser window, you should probably ask WHY he's doing it. In certain situations a new window has to be opened, or a client wants it that way.
4:36 pm on May 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 16, 2007
posts:846
votes: 0


@stoutfiles +1 - I remember asking a similar question [webmasterworld.com] and decided to preface it with a disclaimer - just to avoid this type of OT discussions.

A member with several hundred posts under his or her belt should probably be trusted to have considered any usability implications, right? Right? :)
5:00 pm on May 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


<span onmouseover="this.style.cursor='pointer'" onclick="clickTrack(); return false;" onMouseDown="clickTrack(); return false;">


Just don't use span, use an anchor. You have a bunch of code there not needed to force the span to do what you want when an anchor does this inherently.

Example [webmasterworld.com] (so the user knows it's a new window - but you will need to remove the target attribute.)

Not mentioned here is the pain of popup blockers, the previous example addresses that as well.

There are very good reasons to use a new window, many times they are not good reasons and indeed invalid, so the original source is STILL spot on. Some things don't change.

It's also interesting that target is coming back in HTML5.

[edited by: rocknbil at 5:04 pm (utc) on May 10, 2010]

5:12 pm on May 10, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts:4965
votes: 10


@TheMadScientist, lavazza:
The Jakob Nielson article referenced earlier in this thread was, indeed, from 1999. However, it was updated in 2007 [useit.com] and still included that item as one of the top 10 mistakes. Most of it remained the same, but with this addition:

Links that don't behave as expected undermine users' understanding of their own system. A link should be a simple hypertext reference that replaces the current page with new content. Users hate unwarranted pop-up windows. When they want the destination to appear in a new page, they can use their browser's "open in new window" command -- assuming, of course, that the link is not a piece of code that interferes with the browser’s standard behavior.


In other words, if links are created that don't modify the browser's standard behavior (replace current content with the content of the link), then users have the option of opening the link in the standard way, or opening in a new window/tab. The reverse is not true. If you force a new window/tab, you've taken that control away from the user.

@StoutFiles, caribguy:
Because opening new windows has LONG been established as bad practice, I don't think anyone should be surprised when someone brings up the subject whenever a poster asks how to do it. Having several hundred posts in no way implies any knowledge about usability experience. And doing it because "a client wants it that way" is not a good reason. "The Client" who wants it that way is probably not a usability expert. They hire a developer for their expertise and knowledge, so it's up to the developer to point out that, "hey, this is considered bad practice and let me explain why...".
5:42 pm on May 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2606
votes: 0


Opening up new browser windows is like a vacuum cleaner sales person who starts a visit by emptying an ash tray on the customer's carpet. Don't pollute my screen with any more windows, thanks (particularly since current operating systems have miserable window management). If I want a new window, I will open it myself!


I don't agree with this sentiment.

Many users aren't even savvy enough to upgrade to a modern browser, to expect they know the procedure to open links in a new browser on their own is a huge assumption.

IMO:
PDFs, .xls, .doc should always open in a new window. (or tab)
Offsite links often can open in a new window. (or tab)
Printable receipts should always open in a new window. (In fact I like all my printable pages to open in a new window. I remove nav links and such from my printable pages. Giving someone a dead end page like that in their current browser seems like a really bad idea.)

I set my browser so that new windows open in a new tab instead to protect my screen real estate.

"a client wants it that way" is not a good reason


I think the client wanting it that way is the best reason to do it. Of course it is your duty to explain why it may not be a good idea and to explain both the up and the down side of this practice but if the client wants it and the client is paying then you do it for the client.

Just because it is considered "bad practice", isn't reason to warn people off it everytime it comes up in a thread, there are still plenty of real world use-cases to do this and it not be "bad".
5:52 pm on May 10, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts:4965
votes: 10


Well put. I should have clarified that I do feel there are SOME valid cases for opening a new window. My intention, though, was to point out that discussion about this is always valuable.
6:01 pm on May 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2606
votes: 0


discussion about this is always valuable.


I agree 100%, knowledge is power.

System

7:26 pm on May 10, 2010 (gmt 0)

redhat

 
 


The following 9 messages were cut out by jatar_k.

[edited by: jatar_k at 7:02 pm (utc) on May 11, 2010]