davemaxwell
Access 2000 Support Moderator
    
USA
3020 Posts |
Posted - 08 August 2000 : 15:36:12
|
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> </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> |
|