Have Links Open In Same Window - Posted (2803 Views)
Senior Member
leatherlips
Posts: 1838
1838
I would like to have any links in a topic that point to somewhere in my own domain to open in the same window. Currently any link in a post always opens in a new window.
Can it be set to open in the same window if it is still in my domain and open in a new window if it is outside my domain?<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Support Moderator
Shaggy
Posts: 6780
6780
I have some code for that which I seem to recall posting here; let me have a search around ...
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Support Moderator
Shaggy
Posts: 6780
6780
Here's the original topic and here's the file that I was linking to.
Actually unearthed that in this topic where I helped you do something similar on default.asp! wink
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
leatherlips
Posts: 1838
1838
Thanks Shaggy. I knew I had asked this before but didn't search for it. blush
Anyway, I replaced the URL function in inc_func_common.asp with your code and all links now open in the same window.
Here is my test page:

http://www.mangionemagic.com/forum/topic.asp?TOPIC_ID=804

The first two links are within my own site and I want them to open in the same window (which they are currently doing).
The second two links are outside of my domain and should open in a new window but they also now open in the same window. What am I doing wrong?<
Posted
Support Moderator
Shaggy
Posts: 6780
6780
My domain is hardcoded into that function so you'll need to change all occurrences of WOO.IE to MANGIONEMAGIC.COM
Also note that I use my own JS function in that file to spawn new windows so you'll also need to change all occurrences of onclick=""return tL(this,'e');"" to the appropriate target attribute.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
leatherlips
Posts: 1838
1838
Thanks Shaggy. I need one more bit of help. blush
How exactly do I change this:
Code:
onclick=""return tL(this,'e');""
I tried
Code:
onclick=""TARGET=_BLANK;""
but it does not work.
Right now all links inside and outside of my forum open in the same window.
Also, am I supposed to replace the entire url function with your code or add it to the existing code? I currently replaced the whole thing. However, your code is much shorter than what I replaced. Perhaps I took out something I shouldn't have?<
Posted
Support Moderator
Shaggy
Posts: 6780
6780
Drop the onclick event completely and just use the target attribute. That function has been pretty heavily edited, mainly to make it more compact; other than what I've already mentioned, I don't think I've made any other changes that would effect its compatibility with a base Snitz install but it's a few years since I customised it so keep a copy of the original function to hand just in case things start going askew.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
leatherlips
Posts: 1838
1838
I can't get it to work.
Here are the two spots with the onclick. What do I do to them?
oTag=" c1Tag=" target="_blank" rel="noopener noreferrer nofollow" title="">"
oTag2="[url="http://"
c2Tag=""]"
c2Tag="
"
roTag="<a href="""
rc1Tag=""" onclick=""_BLANK;"">" rc2Tag="</a>"
rc3Tag=""">"
oTagPos=instr(1,strToFormat,oTag,1)
c1TagPos=instr(1,strToFormat,c1Tag,1)
if oTagpos>0 and c1TagPos>0 then
strArray=split(strToFormat,oTag,-1,1)
for Counter=0 to ubound(strArray)
if instr(1,strArray(Counter),c1Tag,1)>0 then
strArray2=split(strArray(Counter),c1Tag,-1,1)
strArray2(0)=replace(strArray2(0),Chr(34)," ")



ReplaceURLs=ReplaceURLs&"<a href="""&strArray2(0)&""" onclick=""_BLANK;"">"&strFirstPart&"</a>"&strSecondPart
elseif ucase(left(strArray2(0),7))="HTTP://" then
ReplaceURLs=ReplaceURLs&roTag&strArray2(0)&rc1Tag&strFirstPart&rc2Tag&strSecondPart
elseif ucase(left(strArray2(0),8))="HTTPS://" then
ReplaceURLs=ReplaceURLs&roTag&strArray2(0)&rc1Tag&strFirstPart&rc2Tag&strSecondPart
elseif ucase(left(strArray2(0),4))="WWW." then<
Posted
Support Moderator
Shaggy
Posts: 6780
6780
oTag="[url="""
c1Tag="""]"
oTag2="[url]"
c2Tag="[/url]"
roTag="<a href="""
rc1Tag=""" target=""_blank"">" rc2Tag="</a>"
rc3Tag=""">"
oTagPos=instr(1,strToFormat,oTag,1)
c1TagPos=instr(1,strToFormat,c1Tag,1)
if oTagpos>0 and c1TagPos>0 then
strArray=split(strToFormat,oTag,-1,1)
for Counter=0 to ubound(strArray)
if instr(1,strArray(Counter),c1Tag,1)>0 then
strArray2=split(strArray(Counter),c1Tag,-1,1)
strArray2(0)=replace(strArray2(0),Chr(34)," ")



ReplaceURLs=ReplaceURLs&"<a href="""&strArray2(0)&""" target=""_blank"">"&strFirstPart&"</a>"&strSecondPart
elseif ucase(left(strArray2(0),7))="HTTP://" then
ReplaceURLs=ReplaceURLs&roTag&strArray2(0)&rc1Tag&strFirstPart&rc2Tag&strSecondPart
elseif ucase(left(strArray2(0),8))="HTTPS://" then
ReplaceURLs=ReplaceURLs&roTag&strArray2(0)&rc1Tag&strFirstPart&rc2Tag&strSecondPart
elseif ucase(left(strArray2(0),4))="WWW." then

<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Posted
Senior Member
leatherlips
Posts: 1838
1838
Posted
Support Moderator
Shaggy
Posts: 6780
6780
You're welcome, mate smile
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
You Must enter a message