FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


I need help with CSS





phileplanet
does anyone know if you can use CSS to open all links in a new window?
i'm building a website that depends on this so please help me.
CrimsonStrange
I've found that this simple tag, placed within your <head></head> tags will do the trick:

<base target="_blank">

Also, look here for more info -

http://vancouver-webpages.com/META/metatags.detail.html#Window-target

or here http://www.mompswebdesign.com/html/target.html


Best of luck! Smile
Bookface
This isn't possible through CSS.

CSS is purely for styling purposes. You can do the following to selectively style links that open a new window:

Code:
a[target="_blank"] {
background: url(newwin_icon.gif) no-repeat;
}


but you can't make them that way in the first place.
The <base target="_blank"> code is the best way I know of to achieve this (or alternatively, use javascript to rewrite the links.)


Perhaps you should rethink why you want to do this in the first place, though. The right to choose their window should come from the user, and can be overwritten in many browsers anyway. Also, there are cases where multiple-window browsing is not an option.
progman89
You're supposed to do it like this...
Code:

<head>
<base target="TARGET">
</head>

It doesn't go in the CSS.
phileplanet
I knew CSS was only for styles actually but i thought you could use the classes or something like that instead of writing
Code:
target="_blank"
like 500 times. I would have put
Code:
base target="_blank"
in the head but it would open my navigation links in a new window. Anyway, i just pasted the target attribute in the end so thank you everyone for all you help. If anyone finds a solution for this, leave me a pm or email me.

::Board Closed::
budazz
i think your topic is not for here mybe you should post to the scripting area...and you can get many replies... Very Happy
Summer
Quote:
does anyone know if you can use CSS to open all links in a new window?


CSS cant do this . CSS is just for the layout of website .
orno
budazz wrote:
i think your topic is not for here mybe you should post to the scripting area...and you can get many replies... Very Happy


--moved--
jlbribeiro
Quote:
CSS is purely for styling purposes. You can do the following to selectively style links that open a new window:

Código:
a[target="_blank"] {
background: url(newwin_icon.gif) no-repeat;
}


but you can't make them that way in the first place.
The <base target="_blank"> code is the best way I know of to achieve this (or alternatively, use javascript to rewrite the links.)


target tag is normally used for defining which frame should be the target but that works too. Through CSS I don't know, but Bookface looks like he knows about this matters.
friscofrankie
As you may have found out, the "target='xxx'" attribute is depreciated in the strict DTDs.
I have one advertiser I want my users to consult while perusing my site and I want my site XML/XHTML stric compliant. If you're in the same boat, and "targetr='xxx'" is casuing your site to puke. This little java function oughta help you out
Code:

<a onclick="javascript:window.open('http://www.yourlink.root');">


FF
davmcmul
No matter how you do it, making links open in anew window is a bad idea. It's much better to assume that the user has sufficient intelligence to use the back button or to right-click and open in new window when *they* want to. Give the choice to the user Wink
friscofrankie
davmcmul wrote:

It's much better to assume that the user has sufficient intelligence


Where's that"laughing may ass of rolling on the floor" smiley?
While occasionally a user will surprise me with some modicum of intelligence the majority of users browsing have short attention spans and will click and click until they are lost in a maze and can't remember how to get back to your site even if they were keenly interested. This being the case, if you have good reason for wanting the user to have comparative data while checking your website open a new window.
I hate it when a site does this to me. But having been in the IT business for over 16 years and writing code since 1984,I may be considered in the 'web-elite" If you want to present your information to the general public, you must code to lowest common denominator. If your page is coded for only Firefox users or technical personell leave that "new window" feature out. If you have a page of links of related or unrelated data let the user decide to" new window" or not. There is always going to be grey area where the purist's and the general public's needs part ways. Code for yor audience.
Related topics
CSS/Layout Help Please!
help explaining error messsage from CSS validator
CSS Help needed : Table emulation with divs
CSS Help...
Help wanted with CSS and iframes It works
Need Help With CSS
Help me in CSS
Help Me set css for my blog
Help setting a css for the sidebar : Blog
Basic CSS help needed regarding IE vs FF
Joomla CSS Help Just like any CSS Help
A little Help (Html,CSS, javascript)
horizontaal menu
Xhtml errors help...
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.