AXiSS Posted February 1, 2007 Share Posted February 1, 2007 I want to use target="_blank" in my links, but I'm using XHTML and when I go to validate my code, it says that the attribute "target" does not exist. How do I get around this? Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/ Share on other sites More sharing options...
cmgmyr Posted February 1, 2007 Share Posted February 1, 2007 The only thing that you can use (easily) is JS: onclick="window.open(this.href,'_blank');return false;" Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-174148 Share on other sites More sharing options...
ToonMariner Posted February 1, 2007 Share Posted February 1, 2007 if you are making the site accessible also use: onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;" you don't need the _blank in there... Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-174447 Share on other sites More sharing options...
fenway Posted February 1, 2007 Share Posted February 1, 2007 See, this is why validation is silly.... Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-174606 Share on other sites More sharing options...
lando Posted February 1, 2007 Share Posted February 1, 2007 You might just try setting your doctype to xhtml transitional, which does allow for target, strict does not. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-174985 Share on other sites More sharing options...
AXiSS Posted February 1, 2007 Author Share Posted February 1, 2007 You might just try setting your doctype to xhtml transitional, which does allow for target, strict does not. Hmmm... will anything freaky happen to my formatting if I switch? Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-175035 Share on other sites More sharing options...
cmgmyr Posted February 1, 2007 Share Posted February 1, 2007 there might be some stuff that gets messed up Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-175055 Share on other sites More sharing options...
lando Posted February 2, 2007 Share Posted February 2, 2007 You'll never know until you try it... Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-175105 Share on other sites More sharing options...
AXiSS Posted February 2, 2007 Author Share Posted February 2, 2007 Well, let me pose the question this way: will going to Trans. more likely fix the FF display problems or make them even worse? Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-175119 Share on other sites More sharing options...
lando Posted February 2, 2007 Share Posted February 2, 2007 I don't believe going down from strict to transitional will effect it. Going the other direction and there would be issues. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-175130 Share on other sites More sharing options...
worldworld Posted February 2, 2007 Share Posted February 2, 2007 Please write the code here so that, we see the whole code and tell relevant steps to be taken... Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-175428 Share on other sites More sharing options...
ToonMariner Posted February 2, 2007 Share Posted February 2, 2007 See, this is why validation is silly.... Why? This is all in line with web standards. Opening a page in a new window is most definitely a document efect and as such should be implemented with javascript. The window.open(this.href); retrun false; method is perfect because it allows js to control the effect and degrades when js is off to opening in teh current window. If you want to use the target attribute and remove the document from the realm of js control then just use a different doctype its not compicated. If you are using a strict doctype then code as such - as compliant browsers SHOULD fail if you don't (unfortunatley they still work!!!!!) Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-175784 Share on other sites More sharing options...
fenway Posted February 5, 2007 Share Posted February 5, 2007 Really? Frames aren't JS, and they have a target... Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-177192 Share on other sites More sharing options...
ToonMariner Posted February 5, 2007 Share Posted February 5, 2007 Frames DON'T have a target in xhtml1.1. Target is NOT a valid attribute for a frame (and never has been). A frame has a name or id that in html can be referenced to using the target attribute of a anchor. Standards however consider any content not loading into the current window a document effect; and if you are clicking a link in one frame to do something in another then that is classed as a document effect - hence javascript should control that. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-177394 Share on other sites More sharing options...
fenway Posted February 5, 2007 Share Posted February 5, 2007 I meant that you can target anchors... which should always work, even with JS off... it's been around for a decade without JS. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-177484 Share on other sites More sharing options...
tarun Posted February 5, 2007 Share Posted February 5, 2007 Errmm Whats XHTML? PM Thnx Tarun Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-177498 Share on other sites More sharing options...
lando Posted February 5, 2007 Share Posted February 5, 2007 I believe if you are using frames and xhtml you have to use doctype frameset. http://www.w3schools.com/tags/tag_doctype.asp Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-177690 Share on other sites More sharing options...
ToonMariner Posted February 5, 2007 Share Posted February 5, 2007 I meant that you can target anchors... which should always work, even with JS off... it's been around for a decade without JS. Yes but as opening a new window is considered a document it should be controlled by js. Standards state that you xhtml/html should be the page content, the design be done in css and the doc effects in js. xhtml should NOT control any documenst effects - thats why the target attribute was no included in the xhtml1.1 standard (nor xhtml1.0 if my memory serves me right.) Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-177807 Share on other sites More sharing options...
fenway Posted February 6, 2007 Share Posted February 6, 2007 I understand what the standards "state"... I just think it's inconsistent with what's been around for a long time. But that's just me. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-178158 Share on other sites More sharing options...
SweetLou Posted February 11, 2007 Share Posted February 11, 2007 fenway, I used to think like you do, but I now know better. Standards are a good thing. They make authoring a webpage so much easier. If you want to use the target attribute, then either use a different common doctype or create your own. The original poster decided to use xhtml 1.1 strict, then that person should code to that standard. Your knowledge, expertise and willingness to help with sql is admired, but as you know, how you do something in MySQL 3 might be different in MySQL 5, this is kind of like how it is in xhtml 1.1 strict or html 3, if you decide to use one over the other, than you need to follow those standards. I prefer to use xhtml 1.1 strict, since IE follows that a little closer than the other standards and it makes it a little easier to add a few hacks to make IE look the same as opposed to other standards. Oh, and for the original poster, yes I do mean IE, not FireFox. FireFox is not perfect with its standards, but it is a lot closer than IE. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-181769 Share on other sites More sharing options...
fenway Posted February 11, 2007 Share Posted February 11, 2007 Nothing about forcing me to author something differently than I want to is "easier". Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-182284 Share on other sites More sharing options...
SweetLou Posted February 11, 2007 Share Posted February 11, 2007 Yes, it would be easier, but you won't get the same results in all browsers, whereas if you had standards then your page would look like you want it to look in all browsers. If you want to code in your own way, you could just make your own doctype and have the browsers follow that standard. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-182305 Share on other sites More sharing options...
Daniel0 Posted February 12, 2007 Share Posted February 12, 2007 Errmm Whats XHTML? PM Thnx Tarun Seeing as you're an HTML expert (according to your signature) you really should have heard about XHTML. While HTML is short for HyperText Markup Language, XHTML is short for Extensible HyperText Markup Language. XHTML is meant to supersede HTML and uses a XML structure (really ultra short description). More information here. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-183090 Share on other sites More sharing options...
fenway Posted February 13, 2007 Share Posted February 13, 2007 Yes, it would be easier, but you won't get the same results in all browsers, whereas if you had standards then your page would look like you want it to look in all browsers. If that were even true at all, I might actually consider using them... Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-183615 Share on other sites More sharing options...
ToonMariner Posted February 13, 2007 Share Posted February 13, 2007 its not true but the use of standards will give 'better' results across browsers. You will produce a site that is much closer in look and feel on many browsers. Honestly, I have not used a hack in css for some time now (alothough I don't support ie 5.5 these days) and nor do I use any scripts to switch style sheets - one sheet and the same html served to all devices - and the results are pretty damn good even if I do say so. I promise you - switch to strict xhtml 1.0 or better still xhtml 1.1, use only valid mark up, stick ALL style in css and leave ALL doc effects to js - ensuring they degrade nicely (I use ajax alot for this as it also reduces the server load a little and improves user experience vastly) and in a few weeks you will sit back and wonder why the hell you didn't make the switch sooner... That is a promise. Quote Link to comment https://forums.phpfreaks.com/topic/36566-target_blank-in-xhtml/#findComment-183656 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.