Click to See Complete Forum and Search --> : ASP/VBSCRIPT


jwestmoreland
August 25th, 2000, 02:15 PM
I am trying to redirect a page and strip out the following code using ReplaceText:

show_ad(3);

I have tried using the following regular expression without success

strHTML = ReplaceText(strHTML,"[\s]*show_ad\([\d]\);", "")

Would greatly appreciate any suggestions

soar
August 25th, 2000, 03:09 PM
Try using the Replace() method

Dim Manufacturer

Manufacturer = "General Motors"
Manufacturer = Replace(Manufacturer, " ", "_")

The value now is:
Manufacturer = "General_Motors"

jwestmoreland
August 25th, 2000, 03:22 PM
I tried using replace without luck

Thank you.

soar
August 25th, 2000, 03:48 PM
Show us an example of what the initial value of strHtml could be.

And also, what you would like to see as its final value.

jwestmoreland
August 25th, 2000, 03:52 PM
Initial input is
(all Javascript calls )
show_ad(1);


show_ad(2);


show_ad(3);


I would like to completely remove
all of these function calls.

Thank you

soar
August 25th, 2000, 04:16 PM
I still do not know what else could be contained in your strHtml.

eg:
Dim strHtml
strHtml = "http://www.msn.com?fxnName1='show_ad(1)'"

strHtml = Replace(strHtml,"show_ad(1)","")
strHtml = Replace(strHtml,"show_ad(2)","")
strHtml = Replace(strHtml,"show_ad(3)","")

strHtml = Replace(strHtml,"?","")
strHtml = Replace(strHtml,";","")

strHtml = Replace(strHtml,"fxnName1","")
strHtml = Replace(strHtml,"=","")

strHtml = Trim(strHtml)

'Now strHtml is
strHtml = "http://www.msn.com"

Response.redirect(strHtml)

'Or Use
Dim retVal
retVal = Instr(1, strHtml, "?")
strHtml = Left(strHtml,retVal-1)

jwestmoreland
August 29th, 2000, 02:16 PM
strHTML is the HTML from a web page. In this case, the string I'm trying to replace is inside a Javascript statement which looks like this:

TABLE BORDER=0 CELLPADDING = 10 CELLSPACING=0
TR
TD ALIGN = CENTER VALIGN= middle
SCRIPT LANGUAGE = "Javascript" TYPE= "text/javacript".
!--
show_ad(1);
-->
/SCRIPT
/TD

I took out the "" portion of the tag so this text would display!
I'm trying to strip out the function calls to the show_ad function, because it pops out of my frame. Thanks for your help.

Johnny101
August 29th, 2000, 05:22 PM
i guess you are editing the source files then - correct? anyway, after you get all the html file's source (strHTML), since it's javascript - you'll have to use the javascript comment line (//). then try this:

'the source is in strHTML
strHTML = Replace(strHTML,"show_ad(", "// show_ad(")

'now save it back




so, your code before would be:

TABLE BORDER=0 CELLPADDING = 10 CELLSPACING=0
TR
TD ALIGN = CENTER VALIGN= middle

SCRIPT LANGUAGE = "Javascript" TYPE= "text/javacript".
!--
show_ad(1);
-->
/SCRIPT

/TD

'has now become

TABLE BORDER=0 CELLPADDING = 10 CELLSPACING=0
TR
TD ALIGN = CENTER VALIGN= middle

SCRIPT LANGUAGE = "Javascript" TYPE= "text/javacript".
!--
//show_ad(1);
-->
/SCRIPT

/TD





by not specifying a value for the show_ad(index) - you get them all, if there's only one, then only one will be replaced, if there's ten "show_ad(" will show up 10 times, and be replaced ten times with the jscript commentor infront - rendering it disabled.

hope this helps,

John

John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org