Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Opening Hyperlink In New Window Using Xhtml 1.0 Strict
csp4.0
post 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.
Go to the top of the page
 
+Quote Post
jlhaslip
post 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 Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
rvalkass
post Jan 29 2008, 07:16 AM
Post #3


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,056
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
bthaxor
post 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
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
csp4.0
post 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 happy.gif
Go to the top of the page
 
+Quote Post
Liam_CF
post 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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Did You Face Problem Opening Pdf With Firefox?(14)
  2. [help] Java Script: Window.open(8)
  3. Photoshop Registration(6)
  4. Window Media Player Or Winamp?(34)
  5. How To Reference Parent Browser Window From.....(2)
  6. Javascript Close Window(12)
  7. Auto-opening Toilet-seat(32)
  8. Maintaining Browser Size On Your Computer(4)
  9. Windows Vista Gui Vs Window Xp Gui(17)
  10. No Google Talk For Linux?(6)
  11. Questions About Xml, Xhtml(3)
  12. How To Restore Show Desktop Icon(3)
  13. Window Media Player License.(1)
  14. Top Tips When Opening An (online) Business(7)
  15. Explorer.exe Problem When Opening Document(6)
  1. How Xhtml Is Different From Html?(2)
  2. Opening Port(0)
  3. Window Xp Registry Tweaks(0)
  4. Php An Js Window.open Pages Trouble.(3)
  5. The Opening Guitar Bit To "you're Beautiful"(3)
  6. Remote Desktop Connection(7)
  7. Technology Identifies Invisible Intruders On Wireless Lans(0)
  8. Opening Large Programs With Ms Word(0)
  9. Window Shortcut(0)
  10. Xhtml Input Field Problem(1)
  11. Opening Nat On Your Xbox - Upnp With Netgear(0)
  12. Opening Nat Requests(0)
  13. Surf Internet Without Opening It. Useful For School(5)


 



- Lo-Fi Version Time is now: 26th July 2008 - 03:45 PM