Current status of the Ning Platform is always available on the Ning Status Blog.

Hello NCs.

 

I'd like to share this great tip I found in the past on creators. I do not remember the original author and please post here if you know. I do not mean to take the credit but I'd like to share this tip and ask for your advice.

 

Paste this in your custom code.

 

<script language="JavaScript">
var myLinks = document.getElementsByTagName('a');
for (x in myLinks) {
if(myLinks[x].href != null) {
if(!(myLinks[x].href.match(/Yournetworkurl.com/))) {
//set external links to open in new window
myLinks[x].target = '_blank'; }
}
}
</script>

 

You have to change the "Yournetworkurl.com" with your website address. \

If you try on the test network make sure you use the test network address otherwise all links will open in new window.

 

Question... Can anyone adapt the code to include additional domains? for example I wanna exclude some addition websites so they will not open on new window but on the same..

 

Can anyone help?

You need to be a member of Ning Creators Social Network to add comments!

Join Ning Creators Social Network

Votes: 0
Email me when people reply –

Replies

  • Found the solution... If you would like to exclude additional domains just repeat this line

    if(!(myLinks[x].href.match(/Yournetworkurl1.com/)))

    if(!(myLinks[x].href.match(/Yournetworkurl2.com/)))

    if(!(myLinks[x].href.match(/Yournetworkurl3.com/)))

     

    Hope you find it useful...

  • Does anyone know how to change the default option when add links in text editor? For my site it seems always default to new window. But I see Jen's site it default to same window.

    And thanks for sharing the code. But the performance seems not that good. Because if you have 100 links in a page. It will runs 100 time no matter user click any link or not. The better solution is to bind the event action with toper element, such as document or body. And then check if it's a out or in-going link when mouse clicked. This will run 100 time only when user click 100 time. :P

    • Alex,

       While in the text editor, and after making the hyperlink, hover over it and click "edit", you will then see an option to choose new window or same window. no idea why the option isn't given to you to begin with, though.

      • Thank you Speed Racer, 

        I've doing this to change the links all the time. Just wonder why we can't have the options to choose new window or same window when we first add links. 

  • Thanks a lot Spyro for this tip, it is just what I needed!

    I needed to take away the first / though, so it ended like:
    if(!(myLinks[x].href.match(Yournetworkurl.com/))) {

    I don't know why, but with the / in the begining it wasn't recognizing the site and opening every page.

    Thanks again!

This reply was deleted.
 

Some interesting articles related to community management, digital marketing etc. could be found in our digest. Don't hesitate to leave a feedback so we would know that we should continue :-)

Latest Activity

Paul Corona replied to Donna MacShoe's discussion
Ning Support phone number for my 20 yr old site
"NING support is useless anymore...I have respnded three times asking questins to a message they…"
Wednesday
Alex - Rosas † Negras posted a discussion
due to personal problems I have not been online anymore, I apologize so much and I am happy to be…
Tuesday
Alex - Rosas † Negras replied to Kos's discussion
Help w/Chat. Ning Support A No Go
"IL PROBLEMA È SEMPRE LO STESSO, NING GLI OPERATORI... DEVONO ELIMINARE I COOKIE SUL VOSTRO SITO"
Tuesday
Vlada replied to Kos's discussion
Help w/Chat. Ning Support A No Go
"I'm no IT expert by any means, but out of curiosity have you tried entering the chat room from the…"
Jan 8
Vlada replied to Eva Libre's discussion
Update, Merry Christmas
"Then add the recent price hike email that Ning has notified to be taking effect soon, I'm not…"
Jan 8
Kos posted a discussion
In November we began to notice Chat "freezing up" and when we would refresh the page, it would…
Dec 27, 2024
Eva Libre posted a discussion
UpdateMerry ChristmasToday I woke up totally frustrated and determined to do something.At the end…
Dec 26, 2024
Eva Libre liked Eva Libre's discussion Ning 3.0 is antisocial!
Dec 25, 2024
Eva Libre updated their profile
Dec 25, 2024
Eva Libre replied to Eva Libre's discussion
Ning 3.0 is antisocial!
"Update
Merry Christmas
Today I woke up totally frustrated and determined to do something.
At the…"
Dec 25, 2024
Pam Givens replied to Pam Givens's discussion
Landing Page
"What I meant to say, if I could spell:
I've attempted to create a landing page and have't had much…"
Dec 12, 2024
Pam Givens posted a discussion
I've attempted to crate a landing page and have't had much success.  I'd rather have one on my…
Dec 12, 2024
More…

Meanwhile, you can check our social media channels