I need to remove the following script from my page(ASP.NET 3.5), leaving all other scripts intact:
<script type="text/javascript">
//<![CDATA[
alert('Save Sucessful.');
</script>
Should be something like $('html').children('script').remove(':contains("alert")) but this exact syntax doesn’t work.
Rather than a pop-up alert, why not provide feedback with a page element (in the DOM)?
It would be there still rather than be there again.
Okay, if you cannot change it you could replace the windows.alert function, if it’s executed before the code in question (usually in DOM order).
BTW, you can’t just test the string (my first thought) since “Successful” should have two ‘c’s and the owner of that code might fix it.
But you could mute all alerts for the first 10 seconds with:
Or, if you want to delete every inline script that contains “alert” you could use:
Note that that pattern matches the script tag in which it occurs, so you could change it if it matters: