User:Richardguk/Test.js

if (document.URL.getParamValue('rgukToAdd')) { var newtext=document.URL.getParamValue('rgukToAdd'); var myelm=document.getElementById('wpTextbox1'); var myvar1=myelm.value; var myvar2=myvar1.replace(/^([^]*)(\s*category\s*:[^\]]*]].*)(.*?)$/igm, '$1$2\n' + newtext + '$3'); alert('was:'+ myvar1.length + ' plus:'+newtext.length+' ='+(myvar1.length+newtext.length)+' new:'+myvar2.length); myelm.value=myvar2; myelm.focus; myelm.setSelectionRange(myelm.value.length,myelm.value.length); }