|
|
|
|
![]() ![]() |
Jan 29 2008, 05:30 AM
Post
#1
|
|
|
NERVE: Interception ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 530 Joined: 14-April 07 From: Holy Terra Member No.: 41,610 |
My website (currently under construction) is all going well until I realized that the XHTML 1.0 Strict DTD does not allow the target="_blank" attribute. How would I find a way around this? I'm used to using XHTML 1.0 Transitional, but I want this website to be Strict for a change.
I would really like it if someone here at trap17 can give me some css that allows them to be opened in a new window. I have searched on Google and only found ways that include writing my own DTD (which I don't want to do), use javascript, and use another doctype. All of those things, I don't want to use. So it would really help if there is any way at all to open up a new window using CSS. |
|
|
|
Jan 29 2008, 05:59 AM
Post
#2
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,882 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
Nope, can't be done via CSS with an XHTML Doctype.
Javascript would be the recommended method, but consider that the rule against opening up new windows is there for a reason. Let the client decide which windows (tabs) get opened in a browser... that is the intent of the restriction in XHTML. |
|
|
|
Jan 29 2008, 07:16 AM
Post
#3
|
|
|
apt-get moo ![]() Group: [MODERATOR] Posts: 2,056 Joined: 28-May 05 From: Hertfordshire, England Member No.: 7,593 ![]() |
In this era of tabbed browsing, different browsers take different understandings to being asked to open a link in a new window. Some take this literally, and so open an entire new browser window, while others take the logical route of opening a new tab. Then there is the possibility that the person viewing your site has ad-blocking or popup-blocking software running. They may well automatically prevent your link from opening a new window. As you can't necessarily be sure what will happen, it is best to go with something that will work instead. Let the browser and user decide what to do. Leave your link with no target, then the user can decide to open a new tab or window if they want, or to open the link in the existing tab/window.
|
|
|
|
Jan 29 2008, 07:27 AM
Post
#4
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 134 Joined: 30-October 07 From: Sydney, Australia Member No.: 52,225 ![]() |
i think in this case, the only method is to use javascript.
i don't understand why you don't want to use javascript - javascript has got to be my favourite web-designing language, since you can do almost anything with javascript (if you really tried, and used document.write a lot, you could even (try to) design a whole webpage with javascript!). i just found a handy code that i used to use (used to because i don't care about validation anymore - all i care about is if it works in all browsers, since my document comes up with 100 errors anyway. i prefer to stick to ' target ="_blank" '). it is javascript, cross-browser and works 100%: CODE addLoadEvent(externalLinks); function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; } } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } then, all you have to add to your links is ' rel="external" '. an example: CODE <a href="somepage.html" rel="external" title="this page opens in a new window">new window link</a> hope i helped. |
|
|
|
Jan 29 2008, 10:12 AM
Post
#5
|
|
|
NERVE: Interception ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 530 Joined: 14-April 07 From: Holy Terra Member No.: 41,610 |
The reason I don't want to use javascript is the fact that I am using a redirection service (www.freedomain.co.nr) and it requires that I put a picture linking back. I can't modify the code so that is why I want a CSS code that opens the normal anchor tags in a new window and manually putting the nostyle tags in the ones I don't want to open to a new window.
But now that I think about it. There doesn't look like a way to do it in the original way, so I guess that the javascript way is the only way. Or I might just 'cheat' and write my own DTD... hehe |
|
|
|
Jan 29 2008, 07:02 PM
Post
#6
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 403 Joined: 14-October 07 From: ERROR 404 Member No.: 51,575 |
Instead of .co.nr you can use .uni.cc which works.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 26th July 2008 - 03:45 PM |