<![CDATA[ target=_blank does not work - My Forums]]> https://forums.modx.com/thread/?thread=17680 <![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97055
">[[Wayfinder? &startId=`0` &level=`3` &parentClass=`hide` &parentRowTpl=`cssplay_parentRow` &outerTpl=`cssplay_outer` &innerTpl=`cssplay_inner` &rowTpl=`cssplay_row` &outerClass=`menu` &cssTpl=`cssplay_basicdd`]]


I haven’t referenced the rel="external" here. I’m referencing it through the weblinks interface. Goto - Site > New Weblink > Link Attributes. Here I have entered rel="external" and I assumed it rendered out in the link tag but nothing happens...???

Is this any clearer?

bS]]>
bigSlim Aug 15, 2007, 03:53 PM https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97055
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97054 smashingred Aug 15, 2007, 01:41 PM https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97054 <![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97053
bS]]>
bigSlim Aug 15, 2007, 10:55 AM https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97053
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97052
Try turning off TinyMCE (or whatever textarea editor you are using) for the page while you are editing it and or place the rel="external" into the link in HTML view. Once you have seen if the script works properly then we can try to address the issue of the link not writing correctly.

Jay]]>
smashingred Aug 15, 2007, 09:31 AM https://forums.modx.com/thread/17680/target-blank-does-not-work?page=2#dis-post-97052
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97051
Im not getting this working? I’ve added in all the JS but on entering rel="external" into the link attribute field and then checking the source code it isn’t showing in the a tag??

How do you get this to work?

bS]]>
bigSlim Aug 15, 2007, 07:21 AM https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97051
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97050 ...the target attribute is NOT deprecated anymore in HTML5...
While this is true today HTML5 is not a specification as of yet. The status of the W3C is at the draft stage which is stated in the STATUS section of the Draft copy of the spec. Here is a line from the document:
This is a work in progress! This document is changing on a daily if not hourly basis in response to comments and as a general part of its development process.

I will await the completion of the spec and its recommendations prior to any changes. As it is already, most people don’t fully get that HTML4.01 is the latest version of HTML not XHTML which is HTML as XML application.

@flosoft
My technique (based on Kevin Yank’s) uses the rel attribute and a class name within the URL:

i.e.
<a href="http://www.example-website.com/" rel="external" class="external">Example Website</a>


The javascript that you can either add to the top of your templates or as a chunk is as follows:

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";
 }
}
window.onload = externalLinks;


That code will tell the browser that the URL has a target="_blank" but since it is as a result of DOM and not HTML it will validate.

For me the big thing is in adding the class="external" which will allow me to style the link to distinguish it from in-line document links. What I typically do is place a symbolic background image (in a padded space at the right of the A element) to denote an external link. As well in the title attribute I tell people that the link will open in a new window.

Hope this helps.

Jay]]>
smashingred Jun 17, 2007, 08:35 AM https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97050
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97049
how would I do that with the JS? Is there a snippet for that?]]>
flosoft Jun 17, 2007, 03:19 AM https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97049
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97048 Quote from: smashingred at Jun 17, 2007, 03:57 AM
If you must (at client request) open a new window for a link you should inform the site navigator that they will be leaving the site as well use javascript to do it so that it is valid XHMTL as target="_blank" is not valid HXTML 1.0 or HTML4.01.
While I do agree with you wholeheartedly, and do not use the target attribute on my own sites, you should know that the target attribute is NOT deprecated anymore in HTML5 (reference). The web is in a constant of change smiley

I/we still would recommend you not to use the target attribute though. Or at least don’t use it to open a new window...]]>
sirlancelot Jun 17, 2007, 12:27 AM https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97048
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97047
Back in the 90s people were afraid to have people close their site but usability studies have show time and time again that people who click on links that open in a new window often don’t notice the new window open and then get frustrated when the back button no longer works or they don’t realize a new window has opened and close their whole browser (closing the originating page). if your site is so weak that you can’t afford to send someone to another site and assume that they will come back, you have work to do on your content. Otherwise, don’t link to the site. Absolutely and defintately don’t use target="_blank" for links to your own site as it will disallow people from using the back button.

If you must (at client request) open a new window for a link you should inform the site navigator that they will be leaving the site as well use javascript to do it so that it is valid XHMTL as target="_blank" is not valid HXTML 1.0 or HTML4.01.

Sorry for the diatribe but there is a reason target="_blank" is deprecated in strict doctypes.]]>
smashingred Jun 16, 2007, 10:57 PM https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97047
<![CDATA[Re: target=_blank does not work]]> https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97046 http://beta.esmol.net]]> flosoft Jun 16, 2007, 04:57 PM https://forums.modx.com/thread/17680/target-blank-does-not-work#dis-post-97046