No select text script has a bug in Mozilla. Because the array of tag names to be excluded in NS6+ (Mozilla) is joined into a string before the target tags are tested against it, unintended tags get excluded from the no select text treatment. Here is the array from the demo:Here is the string that results from the join method used:Code:var omitformtags=["input", "textarea", "select"]Here is the test against that string:Code:input|textarea|selectBasically, if the tag's lower case name is in that string, it is exempt from the no select treatment. This will include <input>, <textarea> and <select> to be sure but, also <p> and <a> tags. I've come up with a simple remedy which uses the array as is, without joining it to a string. I've also got a method to exclude these same areas under IE6 but, it co-opts the onmouseup event for those elements. Not such a big sacrifice as other events can be used in most cases to work around that. Here is the code:Code:if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)Hopefully this can be simplified and/or made to append to the onmouseup event in IE for protected tags, rather than co-opting it.Code:<script type="text/javascript"> /*********************************************** * Disable select-text script- © Dynamic Drive (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for full source code * Modified here to exclude form tags properly and cross browser by jscheuer1 ***********************************************/ //form tags to omit: var omitformtags=["input", "textarea", "select"] function disableselect(e){ for (i = 0; i < omitformtags.length; i++) if (omitformtags[i]==(e.target.tagName.toLowerCase())) return; return false } function reEnable(){ return true } function noSelect(){ if (typeof document.onselectstart!="undefined"){ document.onselectstart=new Function ("return false") if (document.getElementsByTagName){ tags=document.getElementsByTagName('*') for (j = 0; j < tags.length; j++){ for (i = 0; i < omitformtags.length; i++) if (tags[j].tagName.toLowerCase()==omitformtags[i]){ tags[j].onselectstart=function(){ document.onselectstart=new Function ('return true') } tags[j].onmouseup=function(){ document.onselectstart=new Function ('return false') } } } } } else{ document.onmousedown=disableselect document.onmouseup=reEnable } } window.onload=noSelect; </script>



Reply With Quote

Bookmarks