More in this section

Forums / Developing with Sitefinity / Hyperlink opening in new window

Hyperlink opening in new window

4 posts, 0 answered
  1. Isaac
    Isaac avatar
    63 posts
    Registered:
    01 Dec 2008
    04 Dec 2008
    Link to this post
    I am trying to get to the onclick event of a Hyper Link control in Sitefinity so I can add the code "onclick="window.open(this.href); return false;" so the link will open in a new window.  I've found instructions on adding a target attribute, however in XHTML 1.0 the Target attribute has been deprecated.  I'm unable to find the templates for the control in the sitefinity files so i can extend them.  Does anyone know where I can locate those templates?  Any help would be greatly appreciated.

    Thank you

    -nathan
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    04 Dec 2008
    Link to this post
    i've been looking into this myself now that I've discovered to my shock and horror that target is depreciated!

    i'm not sure what control you're wanting to change, as I don't believe there is a "hyperlink control" in sitefinity that can be overridden. you can do it in the controltemplates for each module (such as news, blogs, etc)...

    but it occured to me that jquery might be a better solution. you can just setup a class="external" or the rel="external" then call the jquery in the header to populate all of these with javascript for external links!

    here's a great example I found on this very subject:

    http://scottydelicious.com/blog/2008/06/12/xhtml-new-window-links

    i think its RIDICULOUS that this attribute was deprecated, and that now you have to use javascript, which isn't part of xhtml at all to solve it!
  3. Isaac
    Isaac avatar
    63 posts
    Registered:
    01 Dec 2008
    04 Dec 2008
    Link to this post
    Like one of the commenters on that very informative link you provided, I hadn't thought of using jquery to do that, very useful indeed.  In my solution I would have had to implement two additions for links added through the RadEditor and the Hyper Link control, the jquery solution nicely avoids that.

    Looks like Target was deprecated because it was associted with Frames, which have also been deprecated.  So entirely possible it was a case of baby out with the bathwater.  But I've also seen stuff where they thought that a link opening in a new window was a behavior issue, not a content issue, so they deliberately moved it off to javascript.
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    05 Dec 2008
    Link to this post
    Hi,

    A very good discussion.
    Josh, jQuery and external classes sound really good as a solution! I didn't think of it either.

    We have updated your account once again for the recent helpful reply in our forums!

    Regards,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered