Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm trying to slightly modify this so that it prompts for the text to search for, followed by the text to replace with, and when all done processing, show a dialog box letting me know it's done.</p> <p>I plan to use it on a phpmyadmin database edit page that'll have any number of textboxes filled with text (<em>which is what I need it to search and replace in</em>). Also, the text to search for and replace may or may not be multi-line, so I've added the 'm' param in the regex, and also, since I'll be doing searches/replaces that may contain html, they'll often have quotes/double quotes in them. ex:</p> <p>Search for:</p> <pre><code>&lt;img height="76" width="92" src="http://www.gifs.net/Animation11/Hobbies_and_Entertainment/Games_and_Gambling/Slot_machine.gif" /&gt;&lt;/div&gt; &lt;div class="rtecenter"&gt; &lt;strong&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;Vegas Baby!&lt;br /&gt; &lt;/font&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt; </code></pre> <p>and maybe replace with nothing (<em>just to erase all that code</em>), or some other html. So far this is the bookmarklet I've come up with, (<em>javascript, and especially bookmarklets aren't something I mess with often</em>) however, it does nothing as far as finding/replacing, although it does do the prompting correctly.</p> <pre><code>javascript:var%20scrEl=document.createElement('script');scrEl.setAttribute('language','javascript');scrEl.setAttribute('type','text/javascript');scrEl.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js');function%20htmlreplace(a,b,element){if(!element)element=document.body;var%20nodes=$(element).contents().each(function(){if(this.nodeType==Node.TEXT_NODE){var%20r=new%20RegExp(a,'gim');this.textContent=this.textContent.replace(r,b);}else{htmlreplace(a,b,this);alert('Done%20processing.');}});}htmlreplace(prompt('Text%20to%20find:',''),prompt('Replace%20with:','')); </code></pre> <p>Anyone have any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload