Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - removing html tags
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

removing html tags

 Post Reply Post Reply
Author
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Topic: removing html tags
    Posted: 16 September 2003 at 7:04am
In this version of the forum, hovering over a topic link will show (using the "title" property of the link) the first (60? 100?) characters of the post body.

If the first section of the post body contains html tags such as a link, these are completely removed before the "title" property is written.

For example, see this test area posting - there's a link very early in the post, but if you go to the test forum page, when you hover the link title contains only the plain text, ie, the tags have been removed from the text string.

How is this done?

Ta
www.pedalcars.info

The most fun on four wheels

Back to Top
Mikael View Drop Down
Groupie
Groupie
Avatar

Joined: 16 November 2002
Status: Offline
Points: 151
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mikael Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2003 at 12:24pm

Presumably with a filter that strips all the html-tags. Look in functions_filters.asp and see how the tags can be found and stripped out.

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2003 at 1:46pm
<%=server.htmlEncode("string")%>
Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2003 at 2:19pm
Originally posted by Mart Mart wrote:

<%=server.htmlEncode("string")%>


Thanks, but the HTMLEncode function merely encodes what's there, ie:

<a href="link.asp">

becomes

&lt;a href=&quot;link.asp&quot;&gt;

in the HTML of the page, so it renders as text that looks like it should make a link, rather than creating a tag and opening a link.

What I'm after is a method of finding any < and > symbols in the text string and replacing them and everything between any pair of them, such that the entire <a href="link.asp"> section can be taken out, as can any </a>, <p>, </p>, <br />, etc. tags.

If there's a wildcard that can be used in response.replace, that's what I'm after - like

response.replace(strTextString,"<*>","") where * is the wildcard.

As far as I can see, Forum 7.01 doesn't do this but is the latest downloadable version, so I can't check my files!
www.pedalcars.info

The most fun on four wheels

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2003 at 6:34pm

"How can I strip the HTML tags from a text string using regular expressions?"

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=155

Contribute to the working anarchy we fondly call the Internet
Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Posted: 17 September 2003 at 3:27am
Perfect, thanks!
www.pedalcars.info

The most fun on four wheels

Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 17 September 2003 at 3:56am

Here is what I wrote for the next version of the forum, to strip HTML. It doesn't use regular expersions to keep it compatible with ASP2.0 and pre version 5 of the VB Scripting engine:-

'**********************************************
'***    Strip HTML     *****
'**********************************************

'Remove HTML function
Private Function removeHTML(ByVal strMessageInput)

 Dim lngMessagePosition  'Holds the message position
 Dim intHTMLTagLength  'Holds the length of the HTML tags
 Dim strHTMLMessage  'Holds the HTML message
 Dim strTempMessageInput  'Temp store for the message input


 'Place the message input into a temp store
 strTempMessageInput = strMessageInput

 'Loop through each character in the post message
 For lngMessagePosition = 1 to CLng(Len(strMessageInput))

  'If this is the end of the message then save some process time and jump out the loop
  If Mid(strMessageInput, lngMessagePosition, 1) = "" Then Exit For
  
  'If an HTML tag is found then jump to the end so we can strip it
  If Mid(strMessageInput, lngMessagePosition, 1) = "<" Then

   'Get the length of the HTML tag
   intHTMLTagLength = (InStr(lngMessagePosition, strMessageInput, ">", 1) - lngMessagePosition)
   
   'If the end of the HTML string is in error then set it to the number of characters being passed
   If intHTMLTagLength < 0 Then intHTMLTagLength = CLng(Len(strTempMessageInput))

   'Place the HTML tag back into the temporary message store
   strHTMLMessage = Mid(strMessageInput, lngMessagePosition, intHTMLTagLength + 1)


   'Strip the HTML from the temp message store
   strTempMessageInput = Replace(strTempMessageInput, strHTMLMessage, "", 1, -1, 0)
   
  End If
 Next
 
 'Replace a few characters in the remaining text
 strTempMessageInput = Replace(strTempMessageInput, "'", "&#039;", 1, -1, 1)
 strTempMessageInput = Replace(strTempMessageInput, """", "&#034;", 1, -1, 1)
 strTempMessageInput = Replace(strTempMessageInput, "&nbsp;", "", 1, -1, 1)

 'Return the function
 removeHTML = strTempMessageInput
End Function

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.