spell.js
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:2k
- // Checks if the spell checker can be used with this browser
- function browserCompatible() {
- var ua = navigator.userAgent.toLowerCase();
- var isGecko = (ua.indexOf('gecko') != -1);
- var isMozilla = (isGecko && ua.indexOf("gecko/") + 14 == ua.length);
- var isNS = (isGecko ? (ua.indexOf('netscape') != -1) : (ua.indexOf('mozilla') != -1 && (ua.indexOf('spoofer') + ua.indexOf('compatible') + ua.indexOf('opera') + ua.indexOf('webtv') + ua.indexOf('hotjava')) == -5));
- var isIE = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1);
- var versionMinor = parseFloat(navigator.appVersion);
- if (isNS && isGecko) {
- versionMinor = parseFloat(ua.substring(ua.lastIndexOf('/') + 1));
- } else if (isIE && versionMinor >= 4) {
- versionMinor = parseFloat(ua.substring(ua.indexOf('msie ') + 5));
- } else if (isMozilla) {
- versionMinor = parseFloat(ua.substring(ua.indexOf('rv:') + 3));
- }
- var versionMajor = parseInt(versionMinor);
- if (isMozilla || (isNS && versionMajor >= 6) || (isIE && versionMajor >= 5)) {
- return true;
- } else {
- return false;
- }
- }
- // Updates message with the spell checked text
- function updateSpellChecked(str, formname, textarea) {
- eval('document.forms.'+formname+'.'+textarea).value = str;
- }
- // Opens spell checking window
- function popIt() {
- if (browserCompatible()) {
- var n = window.open('about:blank', 'formwin', 'toolbar=no,menubar=no,scrollbars=yes,height=275,width=500,status=no');
- return true;
- } else {
- alert('Spell Checker is only supported in Netscape 6.0+, IE 5.0+ and Mozilla');
- return false;
- }
- }
- // Submits forms in the new window
- // frm = form name
- // box = textarea name
- // html = 1 for wysiwyg editor
- function spellCheck(frm, box, html, path) {
-
- var origMeth;
- var origAction;
- var origTarget;
- var origCmd;
- var retVal = popIt();
- var rFrm;
- if (!html) {
- html = '';
- }
- if (!path) {
- path = '';
- }
- if (retVal) {
- rFrm = eval('document.'+frm);
- origMeth = rFrm.method;
- origAction = rFrm.action;
- origTarget = rFrm.target;
- rFrm.method = 'POST';
- rFrm.action = path + 'includes/spell/compose.spell.php?cmd=procframeset&box=' + box + '&html=' + html + '&frm=' + frm;
- rFrm.target = 'formwin';
- rFrm.submit();
- rFrm.method = origMeth;
- rFrm.action = origAction;
- rFrm.target = origTarget;
- }
- }