Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS: Target = blank all the time 2

Status
Not open for further replies.

vivasuzi

Programmer
Jun 14, 2002
183
Hi!

Can you use a stylesheet to specify that all links should open in a new window.

I already use this

A:Link {text-decoration: none}

Can I add something in there that will make target=blank for all links?

The reason I cannot physically add the target=blank is because sharepoint creates the links at run time and I don't have access to this code. I can however add to the stylesheet.

Any help is appreciated!
Thanks!

[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
Sorry, but there isn't any combination of CSS declarations that can open a new browser window. [sad]
 
More to it: I found this code just now -

<base target="_blank"/>

which works great at opening all the links in a new window. Now my question is what to do with the 3 static links I DON'T want to open in a new window? I have three links on top that use javascript (ie close window, print window) and I need them not to have the target=blank property.

Anyway I can ignore this property in these 3 links only? Or is there another solution besides base target?


[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
I worked around it so I'm sharing in case anyone else wants to try it.

I put the <base target="_blank"/> in the Head tags

Then, I had 3 links that were meant to invoke javascript that I DID NOT want to open in a new window. So I set these 3 links to have no href, and moved the javascript to the onclick.

Then, the links didn't have a hand, which users find confusing. So I added a style to those three links "cursor:hand"

In the end my 3 links were link this:

<a style="cursor:hand" onclick="javascript:print()">

Works for my purposes.

[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
The "cursor:hand" only works in Internet Explorer. You might want to change it to "cursor:pointer; cursor:hand" for other browsers. ;-)
 
rpgfan3233 said:
You might want to change it to "cursor:pointer; cursor:hand" for other browsers.

Unless the target browser audience includes IE 5.0 (or less), using simply "cursor: pointer" will suffice for both IE and other browsers.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
ChrisHunt, Thanks for the suggestion, but trust me the user prefers it in new window.

When we make our website, we make everything open in the same window, as usual.

However, when you make a list in sharepoint, the attachments open in the same window which is actually 10x more irritating than having to close another window. Most people think an attachment opened in a new window so they constantly close the attachment to find that they have also closed the website.

That article says --> "The one thing every web user understands is the "Back" button" This is not true when it comes to attachments. If a MS word attachment opens in the same browser a lot of people *think* it opened in MS word and close it. I sit here daily watching people do that and trying to say "no don't hit the x! hit the back"

So although I agree that when it comes to a webpage you shouldn't use new windows, I believe that you should use new windows if you are taking the user to a different application. Or a different website. Thanks anyway.

On another note, I've worked with people who always go for the X instead of going back and forward. A lot of people do not use the back button, especially those who were thrown into using a computer after 30-40 years of not using one. I've witnessed many people who would close the browser and run the search again instead of going "back" to the search. Now that's irritating.

Oh, and most users are completely unfamiliar with shift+link to open in a new window. At least the people I deal with are.

BillyRay, every computer in the organization has IE 5 or 6, so I'll use your approach. We don't use macs, or Netscape, or anything else. These are internal websites so the only way to get to them is a company computer and I know they all have 5 or 6 or above. So thanks!

[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
I agree with Suzanne about opening attachments in the same window. It is confusing and irritating.

I also absolutely HATE it when a site gives a list of links for you to visit, and when you click on one it replaces the list with the page! It's especially irritating when:

The list is generated by a search, and the search gets rerun when you hit the back button.

The list has more than one "page" and you're not on the first page, but when you hit the back button it takes you back to the first page.

You spend some time wandering around the site you went to, and then have to back, back, back, back, ... to get back to the list.

Google is the worst offender of this. You would think that the way their site is meant to be used would dictate that they open each link in a new window, wouldn't you.

Note: because of these problems, shift-click has become my best friend.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Note: because of these problems, shift-click has become my best friend
But that's the point - you want links to open in a new window, so you shift-click to make it happen. Suppose you're on a site that opens unwanted new windows - it's almost impossible to suppress that behaviour if you don't like it. So - in general - don't open new windows, leave it to the user.

That's not to say that you should never open a link in a new window. Sometimes it's justified - Suzanne's situation may be a case in point (I can't judge). A classic case is where you have a form, and links to pages which provide help on filling it in. Displaying in a new window means that the user can read the help while filling the form, using the same window is awkward, and might discard whatever fields the user has filled in so far.

So, don't throw out that [tt]target[/tt] attribute, but think twice before you use it.

PS
...and then have to back, back, back, back, ... to get back to the list.
You can save yourself some clicking by clicking the little down-arrow next to the back button. It lets you jump back a dozen steps at a time.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Being a firefox user, I hate things opening in different windows, if I want to keep my current page open, I open the new thing in a new tab... Otherwise it should open where it was clicked. Then again, I don't have or want plugins for veiwing word documents or most other OLE types.

Anyway, if the users viewing this site are internal people, and they keep complaining -- then a change is needed. If it's an external site, then either way you'll get compliants and leaving it in the hands of the surfer is best (by not forcing a new window), IMHO.

[plug=shameless]
[/plug]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top