Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grabbing everything but the script
Message
From
13/05/2013 05:22:54
 
 
To
02/05/2013 09:38:18
General information
Forum:
Javascript
Category:
DHTML
Miscellaneous
Thread ID:
01572384
Message ID:
01573657
Views:
63
>>Use Regex to remove the < script > ...... < / script >
>
>Thanks

Prototype.js has a String.prototype method for that:
yourHTML = yourHTML.stripScripts();

you can get the RegExp pattern from Prototype.js source code:
new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>', 'img')
If you need to use $() in both Prototype.js and JQuery.js context, I have this function for you:
if (window.jQuery){ // $() compatible jQuery and Prototype

  true
  && $ // $() exists under firebug
  && $ === jQuery // $() === jQuery()
  && jQuery.noConflict(); // restaure Prototype.js!$()

  $_ = $; // sauve Prototype.js!$()

  $  = function(s){

      if (typeof s !== 'string') return s;

      if (s.replace(/[0-9a-z\-_:\.]/gi, '').length > 0) return jQuery(s); // contient d'autres caractères que ceux admis dans un ID HTML : forcément un sélecteur CSS
      /* ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".") */

      if (s.replace(/[a-z]/gi, '').length > 0) return $_(s); // contient des caractères non alphabétiques - forcément un id

      if (document.getElementsByTagName(s).length > 0) return jQuery(s); // tag

      return $_(s); // id avec seulement des caractères alphabétiques
  };

  Object.extend($, jQuery);
}
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform