javascript - JQuery problem with html() handling in Opera -


I have followed the JS code (stripped at the minimum size where the problem still exists)

< Pre> & lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" src = "jquery.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "debug" & gt; This is & lt; Em> Trial & lt; / Em> & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Var string1 = $ ('# debug'). Html (); Var string 2 = string 1 Location (/ em & gt; / g, ' gt;'); String 2 = String 2.Rail (/ / g, ''); $ ('# Debug'). Html (string 2); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;

Everything works in Firefox and & lt; Em> Tag & lt; Strong> Has been replaced with

But in Opera & lt; Em> Also, any other HTML tags are not captured on regexps.

Is there any way to correct this behavior? Not only do I need to change tags, but also parsing their content (for example, href attributes) is needed.

Opera returns the tag as an uppercase, eg & lt; EM & gt; . You have to change your regular expressions in an insensitive way to work:

  var string2 = string1.replace (/ & lt; em & gt; / gi, '& lt; strong & gt; ; ';); String 2 = string 2 Location (/  / gi, '& lt; / strong & gt;');  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -