Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/Code)
 Choosing whether Links open new windows or not
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

davemaxwell
Access 2000 Support Moderator

USA
3020 Posts

Posted - 08 August 2000 :  15:36:12  Show Profile  Visit davemaxwell's Homepage  Send davemaxwell an AOL message  Send davemaxwell an ICQ Message  Send davemaxwell a Yahoo! Message
There was a discussion sometime before the old forum went down about whether we wanted a link to open a new page or not. Here is the code to do so.

You need a new field on the _CONFIG table, C_INTLINKOPENWINDOW.

In <font color=green>admin_config_system.asp</font id=green>, add the following line to the update of FORUM_CONFIG (about line 89):
<pre id=code><font face=courier size=2 id=code>
strSql = strSql & ", C_INTLINKOPENWINDOW = " & Request.Form("intLinksOpenWindow")
</font id=code></pre id=code>

Add the following code right before the section with the submit button code(about line 213):
<pre id=code><font face=courier size=2 id=code>
<tr valign="top">
<td bgColor="<% =strPopUpTableColor %>" align="right"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>"><b>Use Links Open New Window:</b>&nbsp;</font></td>
<td bgColor="<% =strPopUpTableColor %>"><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
Yes: <input type="radio" name="intLinksOpenWindow" value=1 <% if intLinksOpenWindow = 1 then Response.Write("checked") %>>
No: <input type="radio" name="intLinksOpenWindow" value=0 <% if intLinksOpenWindow = 0 then Response.Write("checked") %>>
<a href="JavaScript:openWindow3('pop_config_help.asp#LinkOpenWindow')"><img src="icon_smile_question.gif" border="0"></a>
</font></td>
</tr>
</font id=code></pre id=code>

in <font color=green>CONFIG.ASP</font id=green>, insert the following into the select of FORUM_CONFIG on line 66(don't forget the <font color=red>,</font id=red> on the field before it):
<pre id=code><font face=courier size=2 id=code>
strTablePrefix & "CONFIG.C_INTLINKOPENWINDOW "
</font id=code></pre id=code>

Add the following line before the MyConn.Close:
<pre id=code><font face=courier size=2 id=code>
intLinkOpenWindow = rsConfig("C_INTLINKOPENWINDOW")
</font id=code></pre id=code>

In <font color=green>inc_functions.asp</font id=green>:
1) Add <font color=red>, intLinkOpenWindow</font id=red> right after the ftype in the edit_href call on lines 44 and 46.
2) replace the edit_hrefs function with this (just added if..else under each ftype, but it's easier to do it this way):
<pre id=code><font face=courier size=2 id=code>
<script language="javascript1.2" runat=server>
function edit_hrefs(s_html, type, intLinkOpenWindow){
s_str = new String(s_html);
if (type == 1){
if (intLinkOpenWindow == 1){
s_str = s_str.replace(/\b(http\:\/\/[\w+\.]+[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"$1\" target=\"_New\">$1<\/a>");
}
else{
s_str = s_str.replace(/\b(http\:\/\/[\w+\.]+[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"$1\" target=\"_top\">$1<\/a>");
}
}
if (type == 2) {
if (intLinkOpenWindow == 1){
s_str = s_str.replace(/\b(https\:\/\/[\w+\.]+[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"$1\" target=\"_New\">$1<\/a>");
}
else{
s_str = s_str.replace(/\b(https\:\/\/[\w+\.]+[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"$1\" target=\"_top\">$1<\/a>");
}
}
if (type == 3) {
if (intLinkOpenWindow == 1){
s_str = s_str.replace(/\b(file\:\/\/\/\w\:\\[\w+\/\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"$1\" target=\"_New\">$1<\/a>");
}
else{
s_str = s_str.replace(/\b(file\:\/\/\/\w\:\\[\w+\/\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"$1\" target=\"_top\">$1<\/a>");
}
}
if (type == 4) {
if (intLinkOpenWindow == 1){
s_str = s_str.replace(/\b(www\.[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"http://$1\" target=\"_New\">$1</a>");
}
else{
s_str = s_str.replace(/\b(www\.[\w+\.\:\/\_\?\=\&\-\'\#\%\~\;]+)/gi,
"<a href=\"http://$1\" target=\"_top\">$1</a>");
}
}
if (type == 5) {
s_str = s_str.replace(/\b([\w+\-\'\#\%\.\_]+@[\w+\.?\-\'\#\%\~\_\.\;]*)/gi,
"<a href=\"mailto\:$1\">$1</a>");
}

return s_str;
}
</script>
</font id=code></pre id=code>

That's it!

Dave Maxwell
--------------
Self Certified Snitz Bug Swatter <img src=icon_smile_big.gif border=0 align=middle>

heptite
Average Member

USA
547 Posts

Posted - 08 August 2000 :  16:03:30  Show Profile  Visit heptite's Homepage  Send heptite an ICQ Message  Send heptite a Yahoo! Message
Thanks, Dave! I like mine to open in a new window, so this gives more configurability.

Sue

<center><font color=purple>
ASPDiva Forum - http://www.aspdiva.com/forum/default.asp
</font id=purple></center>
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000 Version 3.4.07