ผู้ใช้:Bpitk/test.js
จากวิกิพีเดีย สารานุกรมเสรี
หมายเหตุ: หลังจากบันทึกแล้ว, คุณต้องล้างแคชของเบราว์เซอร์เสียก่อน จึงจะเห็นการเปลี่ยนแปลง: Mozilla/Safari/Konqueror: กด Shift ค้าง แล้วกด Reload (หรือ Ctrl-Shift-R), IE: กด Ctrl-F5, Opera: กด F5
/* */ function replace() { var s = prompt("Search regexp?"); if(s) { var r = prompt("Replace regexp?"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "g"), r); } } addOnloadHook(function () { if(document.forms.editform) { addLink('p-cactions', 'javascript:replace()', 'replace', 'ca-replace', 'Regexp replace for the edit window', '', 'ca-history'); } }); /* */