Nov
05

Ever notice that when you go to add an external link page in DotNetNuke that there is no option for it to open in a new window? Well I have two methods that you can go about to get this working on your DNN site. The first, not for the faint of heart, involves a little database work. The second is a quick Javascript fix.

The first method involves tricking DNN’s Tab table to thinking your URL link is something a little bit different.

  • Open up the Tabs Table in your favorite SQL Editor
  • Look for the URL field of the external link you wish to open in a new window.
  • You may see something like: http://example.com
  • You want to make it: http://example.com” target=”_blank

Once you save restart the application in the Host -> Host Settings page and view your link you should be good to go!

The second method is a bit easier however it does use Javascript instead of a normal link.

  • In the external Link field on your DNN Page Settings you will see something like: http://example.com
  • Change it to be: javascript:void(window.open(‘http://www.example.com’))

And save.

A little DNN hacking never hurt anyone.

But it makes you wonder why they do not have this option implemented. And why they don’t validate external URLs when you add them.

About Jim Walker:

Jim Walker is a software engineer and entrepreneur in Northeastern Pennsylvania.

Find all posts by Jim | Visit Website

You can leave a response, or trackback from your own site.

  • swetha

    hi jim i want to know the location of pages in dnn and i need to transfer the pages from system to system can u help me in that

  • Rich Hosek

    Had a problem with filtering something that was “double escaped,” so I changed the single quotes in the javascript example to double quotes and it works fine. Thanks!

  • Swwalsh1981

    hey, if you are like our organization, we have many users who are not going to type that in each time they have to open a link in a new window… they will either forget, type it wrong, etc as they are not techy. For those who want a pretty easy way to do this and have access to your DNN installation… then open up the skin you are usoing  … and at the bottom put this block of code:

    $(function () {        $(‘a:not([href=""])’).each(function () {            if (this.hostname !== location.hostname) {                $(this).addClass(‘externalLink’).attr(‘target’, “_blank”);            }        });    });

    what this does is any EXTERNAL link it will add the target=”_blank” into any links on your page … and as well a class called externalLink so you can make a CSS entry and change stuff around. give it a shot…

  • Swwalsh1981

    i vactually made a mistake in that code. in DNN 6 it uses the popups, so you need to avoid the javascript as well… so this works:

        $(function () {        $(‘a:not([href=""]), a:not([href="javascript"])’).each(function () {            if (this.hostname !== location.hostname) {                $(this).attr(‘target’, “_blank”);            }        });    });

  • Dcalexander

    Hi,

    Tried the 2nd option, not successful.   What is the Tabs Table?  My SQL Editor only browses my computer for a file…

  • Patreddy

    Thanks man, the sql solution worked perfectly.  Rant he query from the SQL module under Host menu.

  • Ahmed Hashem

    Thanks for your great post, It saved me time. :)
    Second method works with me but using double quotes.