View Full Version : RegExp.replace Not Working
SamirDarji
29 Jan 2006, 06:02
I'm using the following function to modify tags used for mouseover text:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
It is being used on the following web page: http://huntsvillecarscene.smugmug.com/gallery/1144571
For some reason, the regexp.replace is not working. There is a test clause in there to help me diagnose some of what's going on.
I'm not a Javascript programmer. I only have a limited background in C. I've been working on this for 2 days and am frustrated out of my mind.
Any assistance appreciated.
filburt1
29 Jan 2006, 06:18
If that is a vBulletin-powered page, it will be easier and cleaner to replace in the HTML output before it's even sent to the browser. Do this via a hook in global_complete (IIRC) on the $output variable.
SamirDarji
29 Jan 2006, 08:36
Unfortunately, this isn't a vb page. :( I don't have almost any control on anything. This was code that was given to me that should work and I've narrowed it down to one test case (dsc00001) just to get it working.
It seems like the .replace isn't working for some reason. In spite of the fact that the re.test works dropping it inside the if.
I've looked at the RegExp documentation for Javascript on devguru as well as other sites. I've looked at examples. Seems like everything is written correctly, but it is still not working. I'm simply dumbfounded. If this was in C, I'd step through the whole thing line-by-line while watching every single variable. But I don't have any tools to do that here. :(
Any ideas?
Marco van Herwaarden
29 Jan 2006, 10:59
Turn on displaying all JavaScript errors in your browser. This might give you a clue.
SamirDarji
29 Jan 2006, 16:53
I will try that. Good idea!
Results--no errors related to that code. (There's one error that's there because of a call to a vb object leftover from a cut-and-paste of some vb generated html.)
Any other ideas? I'm playing with using .match now with some better results, but still unusual things are happenning. :(
filburt1
29 Jan 2006, 17:28
Are you trying to create a title attribute for each image that already has an alt tag?
SamirDarji
07 Mar 2006, 05:24
That's exactly what I was trying to do. I don't understand why I never got the email from vb.org of your response. :( Thank you for your help!
vBulletin® v3.6.12, Copyright ©2000-2009, Jelsoft Enterprises Ltd.