DotNetNuke Skins and Resources by ThinkofDesign

Forums

Subject: How to open menu item in new window
Prev Next
You are not authorized to post a reply.

Author Messages
ericb1 User is Offline
New Member
New Member
Posts: 6


04/13/2007 11:39 PM  

I'm using the Beyond CSS free skin, and I think it's a great skin, thank you. 

I have some links as tabs on the vertical menu, which open an external URL, and I would like to have them open in a new window if possible.  The "open in new window" option isn't available, and I would like to keep them in the main menu, rather in the Links module.

Any help is greatl appreciated, thanks!

Vasilis User is Offline
Yellow Member
Yellow Member
Posts: 315


04/14/2007 06:11 AM  

Unfortunately there is no such functionality out of the box so the only possible solution I can think is using JavaScript.

Put a Text/Html module in your home page and go to this module's settings. Open the Advanced Settings and check the 'Display Module On All Pages?' option. Then below that option in the Header textarea put one of the following scripts.

If you want all items that link to external URLs to open in a new window use the script below:

<script type="text/javascript">
<!--
var menuLinks = document.getElementById('smenu').getElementsByTagName('a');
for(j=0;j<menuLinks.length;j++){
    if(menuLinks[j].href.indexOf('test.thinkofdesign.com') == -1){
        menuLinks[j].target = '_blank';
    }
}
-->
</script> 

Of course you have to replace 'test.thinkofdesign.com' with your URL so the script can identify which items link to internal pages on your site.

If you want to be even more flexible so only specific items to open in a new window, then use the script below:

<script type="text/javascript"> </script>

In the above you have to replace 'Item Title 1', 'Item Title 2' etc. with the titles of the menu items that you want to open in a new window. This is case sensitive. You can add more items by adding another if statement.

And if you don't plan to use this module to put also visible text for your guests, go to the Basic Settings and Uncheck the 'Display Container?' check box so the module will be invisible.

Hope that helps.

Cheers

Vasilis User is Offline
Yellow Member
Yellow Member
Posts: 315


04/14/2007 06:34 AM  

Hmm... The forums keep striping my code in the scripts. I'll try to fix this but till then you can find the scripts in the attached txt.

Sorry about that!


Attachment: How to open menu item in new window.txt

Vasilis User is Offline
Yellow Member
Yellow Member
Posts: 315


04/14/2007 07:22 AM  
OK, scripts look OK also in my first post now!
ericb1 User is Offline
New Member
New Member
Posts: 6


04/15/2007 12:53 AM  

Yes!!!  Thank you so much!

You are not authorized to post a reply.
Forums > DotNetNuke > Free Skins > How to open menu item in new window



ActiveForums 3.7