Closed (won't fix)
Project:
External Links
Version:
6.x-1.6
Component:
Code
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Dec 2008 at 22:08 UTC
Updated:
5 Jan 2011 at 12:48 UTC
What about having jQuery use window.open on the 'ext' class? Since 'target=_blank' is not valid XHTML Strict.
Comments
Comment #1
quicksketchNo it's not valid XHTML strict, but because this attribute is added after page load your pages will still pass validators. Though you're right, since we have a convenient class, we could easily switch to using it instead.
Comment #2
quicksketchAs mentioned in #386988: External Links: add open in new window to statusbar, a good argument not to use JavaScript is the nice status bar message provided by Safari:
Which we only get if using target="_blank" since Safari won't actually interpret a JavaScript popup script that would do the same thing. Of course Safari is the only browser that currently does this, so it's not that strong an argument.
Comment #3
webel commentedI also want XHTML strict compliance.
Would it be possible to introduce an optional settings field where one can introduce one's favourite Javascript "open in new window" hack (rather than hacking it into the external links module, as I'm about to do) ?
Comment #4
webel commentedOr should I say hack external.js.
If the work is done by JavaScript anyway, which not simply have one of the usual JavaScript tricks ?
Comment #5
webel commentedMy hack fails:
It seems that anything written to javascript attributes (like 'onclick') is filtered out.
Does anybody know why, or how I can ensure that 'target' is not used, rather the javascript instead ?
Comment #6
webel commentedThis seemed to work for me (with all caveats, I'm not a jQuery expert):
Comment #7
kentr commentedPopup blockers?
Comment #8
ambrojio commentedIf you can't get the JS to work, assign the "rel" attribute to the link instead of "target", and then use one of the many JS "open in new window" scripts out there, that act on the rel attribute.
This, of course, once again raises the specter of the issue of W3C having deprecated the target attribute. It kind of makes sense to make that a user driven decision, but it's about 4 years ahead of both the general competency of web users at large--to be savvy enough to open external links in a new tab or window--and the expectations of 90% of web site buyers. It's a real pain in my hide, let me tell you.
Comment #9
ambrojio commentedAs a follow up to that, it is possible to obtain XHTML compliant markup without altering the extlinks module at all. Disable the extlinks "open external links in a new window" in the module's admin. You will still have a class="ext" for external links. Then, use whatever method you want to include some Javascript on your page; I have a main.js file that I have a few functions stored in that I am including with drupal_add_js() in my template.php file. In that, I am calling an externalLinks() function in the jQuery equivalent of page.onload:
And the function (adapted from http://perishablepress.com/press/2007/11/20/open-external-links-as-blank...) is:
Comment #10
quicksketchAnyone thinking that "target" should be removed for compliance reasons... well it's compliant again in HTML 5. Figures. http://www.w3.org/TR/html5-diff/#new-attributes
Comment #11
kentr commentedHmm, but what about XHTML. I haven't deciphered that document yet - is it saying that HTML5 replaces XHTML?
Comment #12
quicksketchHTML 5 doesn't replace XHTML currently, but oddly it's what everyone is behind these days (read, Apple, Microsoft, Google, etc.) HTML5 will ultimately replace XHTML in 5 years as much as HTML 4 has been replaced by XHTML, which is never completely of course. It's just rather interesting. Even in XHTML, "target" was merely deprecated (meaning it was planning on being removed eventually), but now it seems that it's going to stick around after all as we move away from XHTML anyway.
Comment #13
AlexisWilke commentedJust my personal point of view, since the links are tweaked with JavaScript anyway, it certainly does not matter whether we have the target="_blank". And also, adding a bind function works too since we already know that JavaScript is available.
But I like the fact that HTML 5 includes the target attribute again. 8-)
My browser also already supports some CSS 3 so I can create shadows and outline, really cool! Can't wait to use that all over my themes.
Comment #14
webel commented> I like the fact that HTML 5 includes the target attribute again
Agree.
Comment #15
iori57 commentedIs 6.x-1.10 still using 'target' or switched to javascript now? Because I can't see 'target' anywhere when I'm viewing the source code now.. but it does open in new window.
Just to clear things up :) Thanks!
Comment #16
quicksketchThe "target" attribute is still used in the latest versions, but it's added by JavaScript, it's not there when the page loads initially.
Comment #17
iori57 commentedThanks for clearing things up!! I'm totally clueless when it comes to Javascript =.=
Comment #18
nancydruSince the class is available, why not something like http://jaspan.com/external-links-in-new-window-without-target?
My big concern is that some of my users already use target="_blank" and I want it removed.
Comment #19
AlexisWilke commentedNancy,
target is valid HTML. Deprecated does not mean dead & buried. Plus, in HTML 5 it's back and HTML 5 is right around the corner. Why bother removing something to put it back in tomorrow?!
http://dev.w3.org/html5/spec/links.html#attr-hyperlink-target
Alexis
Comment #20
nancydruA) it will be duplicated by this module if it is already there.
B) it impacts the teaser length, in many cases reducing it by an entire paragraph.
Frankly, I agree that it should be back - at least until such a time that it can be specified in CSS.
Comment #21
quicksketchThis module doesn't affect the output HTML at all. If you turn off JavaScript you'll see that this module doesn't do anything to the HTML. All changes are done by JavaScript and it does not double-up the target attribute if it already exists.
Comment #22
quicksketchWon't fix'ing per #14. "target" has always worked in every browser, it's back in HTML5, it's never going away, and the mechanism that External Links uses to add the target attribute has no effect on passing validators because the attribute is added by JavaScript. The bottom line is it doesn't cause any problems and it works exactly how people expect right now; there's no need to make any changes.
Comment #23
AlexisWilke commentedNancy,
With my latest patch to the teaser, point #20 (B) is moot and I like that. 8-)
Thank you.
Alexis
See #221257: text_summary() should output valid HTML and Unicode text