ASP Replace in HTML
| Script version: | 1.0 |
| Language: | ASP |
| Rating: |
0 (0 votes cast) |
| Category: | 27 |
| Description: | This function is designed to replace text in HTML strings so that only the non HTML code is replaced. If the searched for phrase is found in the body of the HTML, then the function will firstly check that the phrase is not located inside opening and closing html delimeters, and then secondly will check to make sure that the text is not withing <a> and </a> tags. This means you can replace the text with a glossary link or popup window without affecting the HTML code or the links on the page. The replace function is also case insensitive. If you want the replace function to be case sensitive, then you can change the compare parameter of the instr and instrrev functions. |
| Instructions: | try using the function like this: myHTML = "here is some HTML. I love html <img src="images/i-love-html.gif" alt="Loving the HtML"> this is a <a href="page.html">page about html here</a>." glossarylink = "<a href="#" onclick="window.open('glosary.php#html')">html</a>" myNewHTML = replaceHTML(myHTML,"html",glossarylink) response.write myNewHTML --- this will output: "here is some <a href="#" onclick="window.open('glosary.php#html')">html</a>. I love<a href="#" onclick="window.open('glosary.php#html')">html</a> <img src="images/i-love-html.gif" alt="Loving the HtML"> this is a <a href="page.html">page about html here</a>." |
| Code: | |
Comments
Related Scripts:
Shorten string to maximum lengthconvert string to xml valid text
convert user submitted string to safe format
ASP Capitalize first letter of string
ASP URL Decode
Strip HTML code from string
Tags
[ replace function html ] [View tag cloud]Tag Cloud Submit a script
Latest Scripts Added
Pass null parameter in to parameterized query (ASP.net)10 August 2010
If you try to use a parameterizes query like this: SqlCommand comm = new SqlCommand(); comm.CommandText = "insert into Authors (firstname, surname) values ...
Javascript List all properties for an object (Javascript)
23 March 2010
This code will expose all properities for a javascript object in a new window. Very handy little tool found here: http://www.faqts.com/knowledge_base/view.phtml/aid/8276
c# isNumeric function (ASP.net)
22 March 2010
There is no built in function for isNumeric, however there is a tryParse function that returns true if a string can be converted to a number. A quick and simple method for isNumeric is below.
ASP Hit Counter in Text File (ASP)
11 February 2010
This script will open up a text file and increment the value by 1. Can be used as a page specific hit counter (although using a separate google analytics profile is a better method)
ASP Replace in HTML (ASP)
10 February 2010
This function is designed to replace text in HTML strings so that only the non HTML code is replaced. If the searched for phrase is found in the body of the HTML, then the function will firstly ...
Recommended Sites:

