homepage Welcome to WebmasterWorld Guest from 54.196.195.158
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Browsers / Opera Browser Usage and Support
Forum Library, Charter, Moderator: open

Opera Browser Usage and Support Forum

    
Opera 9.2 9.1 9.0 JavaScript replace regex bug
JAB Creations




msg:4224771
 8:52 am on Nov 1, 2010 (gmt 0)

In my quest for backwards compatibility I've found an odd bug in Opera 9.0~9.2. I get a "Inline script compilation" error for my regular expression because it doesn't have quotes though with quotes the script doesn't work. I'm totally baffled and simply can't find anything, suggestions please?

- John

function smiley_convert(text)
{
if (document.getElementsByTagName('*').length!=0)
{
var smileyTranslator = {
'0:)' : 'angel',
':d' : 'big-grin',
':b' : 'blush',
'?(' : 'confused',
'c(' : 'crying',
'o.0' : 'disbelief',
':>' : 'dork',
'>)' : 'evil-grin',
':p' : 'glee',
':)' : 'happy',
':|' : 'indifferent',
'8)' : 'joe-cool',
':lol' : 'laugh',
':l' : 'love',
':n' : 'nervous',
'n)' : 'nut',
'>__>' : 'paranoid',
':r' : 'reading',
':s' : 'spitting',
'o.o' : 'surprised',
'<.<^' : 'uncertain',
'-__-' : 'unimpressed',
'>:<' : 'vampire',
';)' : 'wink'
};
var converted = text.replace(/0:\)|:d|:b|\?\(|c\(|o.0|:\>|\>\)|:p|:\)|:\||8\)|:lol|:l|:n|n\)|>__>|:r|:s|o.o|<.<\^|-__-|>:<|;\)/g,function (s) {if (s in smileyTranslator) {return '[img]'+path+'images/smiley_'+ smileyTranslator[s] +'.gif[/img]';} return s;});
}
else
{
var converted = ' ';
}
return converted;
}

 

Fotiman




msg:4225025
 6:23 pm on Nov 1, 2010 (gmt 0)

Does it work for any other browsers? Your replace seems to be malformed. It's supposed to take 2 parameters, the regexp/substring to replace and the new string to replace it with. However, I see a function where the new string is supposed to be.

JAB Creations




msg:4226402
 3:26 am on Nov 4, 2010 (gmt 0)

Actually I had help here over in the JavaScript forums with this script and I think I've seen you mod over in the JavaScript forums before. ;)

- John

Fotiman




msg:4226560
 1:28 pm on Nov 4, 2010 (gmt 0)

Ok, I must have missed that thread. Glad you got it working. :)

JAB Creations




msg:4226929
 3:36 am on Nov 5, 2010 (gmt 0)

Thanks Fotiman, though do you have any recommendations on what I could try to get Opera 9 to handle this correctly? Is it a known bug or something?

- John

Fotiman




msg:4227110
 2:47 pm on Nov 5, 2010 (gmt 0)

As I said above, your "replace" seems to be malformed. It's supposed to take 2 parameters, the regexp/substring to replace and the new string to replace it with. However, I see a function where the new string is supposed to be.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Browsers / Opera Browser Usage and Support
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved