Subscribe: RSS
  • Hi,

    I have just noticed, that when creating a Weblink and setting Link Attributes to target=_blank, it isn’t loaded in the menu.

    Here is an example line where the target=_blank is missing in the navigation (using MODx Default template)

    <li class="category "><a href="http://www.eursc.eu" title="EURSC">European Schools</a></li>

    Normally there should be a target=_blank.

    Does anyone know how to fix this?

    Greets,

    Florian
    • target="_blank" ?
        Ryan Thrash, MODX Co-Founder & Leader of Awesomeness
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • still no luck.
        • What are you using to build your menu? If you’re not using Wayfinder and specifically putting in the attributes placeholder in your templates it won’t work.
            Ryan Thrash, MODX Co-Founder & Leader of Awesomeness
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • I am using Wayfinder. Take a look at the site: http://beta.esmol.net
            • While I hope that you solve your technical problem, I hope that you understand the usability no-no that target="_blank" is. Opening URLs in new windows is a cheap tactic that usually backfires on the site owner. You open a new window because you are afraid the people will leave when you really should have decided not to link to the site in question or allow the person to link directly to the document.

              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.
                Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
              • Quote from: smashingred at Jun 16, 2007, 10:57 PM
                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...
                • hey,

                  how would I do that with the JS? Is there a snippet for that?
                  • ...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
                      Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
                    • Hi All

                      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