/************************************************** 鍑芥暟鍚? judgeimg 浣? 鐢? 鍦↖e6鎴朓e7(ie7涓嶅璁歌鍙栨湰鍦版枃浠?ie8鏇翠弗鏍?js鏃犳硶寰楀埌鏂囦欢鍩熺殑value ie9涓嬫渶涓ユ牸,蹇呴』鏈夊彟涓猟iv鐨処d鍙備笌)涓嬪鍥剧墖鍒ゆ柇 inpobj:鏂囨湰鍩焛d|琚檮灞炵殑div鐨処d.娉ㄦ剰,濡傛灉琚檮灞炵殑div鐨処d涓虹┖,琛ㄧず鏂囦欢鍩熸湭琚祵鍦ㄦ鏋朵腑,涓嶉渶瑕乨iv 鍙? 鏁? imgsrc:鍥剧墖鐨勬湰鍦板湴鍧€ containerid:鏀剧疆鍥剧墖鐨勫鍣ㄥ璞$殑id(姣忎釜涓婁紶鍩熶笅閮芥湁杩欎釜) types:1:鏀剧疆鍥剧墖 2:鍒ゆ柇鍥剧墖 3:闈炲浘鐗囧垽鏂?鍙负杩斿洖姝g‘鐨勬枃浠跺悗缂€,姝ゆ椂鍙互鎶奀ontainerid璁句负绌?inpobj涓鸿鍒ゆ柇鐨勬枃浠跺煙鐨勫綋鍓嶅€? 4:娓呯┖鏂囦欢鍩熷唴鍊? 5:img鍦╫nload鍚庤嚜鍔ㄧ缉灏忔樉绀? 杩斿洖鍊? 濡傛灉types涓?,鏃犺繑鍥炲弬鏁?濡傛灉涓?:杩斿洖鍙傛暟鏍煎紡涓?鏄惁杞藉叆|鏂囦欢鍚庣紑|鍥剧墖width|鍥剧墖height|鏂囦欢鍦板潃, 3:闈炲浘鐗囧垽鏂?0:鐩墠鏆傛棤瀹為檯鎰忎箟,鎬绘槸2 1:鏂囦欢鍚庣紑 2:鏂囦欢鍚?涓嶅惈鐩綍) **************************************************/ function judgeimg(inpobj, containerid, types){ var str, tmp, obj, obj1, iever, result, imgsrc; result = true; iever = systemjudge(2); if(types==1){ tmp = inpobj.split('|'); obj1 = document.getelementbyid(tmp[0]); if(tmp.length==2){ if(tmp[1]=='') obj = document.getelementbyid(tmp[0]); else obj = document.getelementbyid(tmp[1]); }else{ obj = null; } if(iever==9){ if(tmp.length==1){ alert('ie9涓嬬己灏戞寚瀹歞iv!'); return; } } //鍦↖e9涓?濡傛灉file鎺т欢鑾峰緱鐒︾偣,鍒檇ocument.selection.createrange()鎷掔粷璁块棶.鍙渶瑕佸湪obj1.select()鍚庨潰鍔犱竴鍙bj1.blur()鍗冲彲,浣嗗鏋滃綋鍓嶉〉闈㈣宓屽湪妗嗘灦涓?鍒欏繀椤昏褰撳墠椤甸潰涓婄殑鍏朵粬鍏冪礌,濡俤iv,button绛夎幏寰楃劍鐐瑰嵆鍙?濡俹bj.focus()銆? //tmp[1]鐨刣iv鐨刣isplay灞炴€т竴瀹氫笉鑳戒负none,鍚﹀垯褰撳皢鍖呭惈鏈湴鐩綍璺緞璁句负绂佹鏃?绋嬪簭灏嗘壘涓嶅埌鍥剧墖鐨勭湡瀹炶矾寰? if(iever==8||iever==9||iever==7){ obj1.select(); try{ //鍥犱负濡傛灉ie9閲囩敤鍏煎妯″紡,姝ゆ椂iever灏辨樉绀?,浣嗗叾瀹夊叏鏈哄埗杩樻槸鎸?鏉ョ殑,鍥犳浣跨敤try imgsrc = document.selection.createrange().text; }catch(e){ //if(obj==obj1) obj1.blur(); else obj.focus(); obj.focus(); try{ imgsrc = document.selection.createrange().text; document.selection.empty(); }catch(e){ if(typeof statusarr!='undefined'&&statusarr instanceof array){ tmp = '璇峰皢鍖呭惈鏈湴鐩綍璺緞璁句负鍚敤锛岃鎯呰鐐瑰嚮鎿嶄綔娴佺▼'; if(foundinarray(tmp, statusarr, -1)==-1){ statusarr[statusarr.length] = tmp; showscrolltxt(0); } } imgsrc = obj1.value; } }; }else if(iever==-1||iever==20||iever==10){ if(obj1.files.item(0)){ try{ imgsrc = window.url.createobjecturl(obj1.files[0]); }catch(e){ imgsrc = obj1.files.item(0).getasdataurl(); //鐏嫄涓?imgsrc鏄浘鐗囩殑鍔犲瘑鍦板潃,浣嗘槸璧嬬粰img鍙瑙堝浘鐗?obj1.files[0].size,obj1.files[0].name鍙繑鍥炴枃浠跺悕鍜屾枃浠跺ぇ灏? } } }else{ imgsrc = obj1.value; } }else if(types==3){ imgsrc = inpobj; } if(types==1){//鏀剧疆 if(typeof containerid=='object'){ //琛ㄧずcontainerid涓嶆槸鍏冪礌鐨刬d,鑰屾槸image瀵硅薄 containerid.src = imgsrc; return; } obj = document.getelementbyid(containerid); if(iever==20){ //ie edge姣旇緝鐗规畩 obj.innerhtml = ''; str = obj1.files[0]; tmp = new filereader(); tmp.readasdataurl(str); tmp.onloadend = function(e){ document.getelementbyid(containerid).firstchild.src = e.target.result; } }else if(iever>6){ //娉ㄦ剰鍦↖e鐨?!doctype html>妯″紡涓?涓€瀹氳display:block!important;,鍚﹀垯鍥剧墖鐨刼ffsetwidth寰楀嚭鏉ョ殑涓? obj.innerhtml = '
'; try{ obj.firstchild.filters.item("dximagetransform.microsoft.alphaimageloader").src = imgsrc; }catch(e){ obj.innerhtml = ''; //濡傛灉ie7浠ヤ笂璁剧疆鍖呭惈鏈湴鐩綍璺緞璁句负鍚?鎴戣繕鏄瀹硅鐢ㄦ埛鐨勫浘鐗囨彁浜ょ殑,鍙槸涓嶈兘瀵瑰浘鏂囧昂瀵歌繘琛屽垽鏂? }; }else{ obj.innerhtml = ''; } }else if(types==2||types==3){ //鍒ゆ柇 result = new array(); result[0] = -1; if(types==2){ obj = document.getelementbyid(containerid).firstchild; if(iever==8||iever==9||iever==7){ try{ tmp = obj.filters.item("dximagetransform.microsoft.alphaimageloader").src; result[0] = 2; }catch(e){ tmp = obj.src; obj = document.getelementbyid(containerid); result[0] = 2; } }else if(iever==-1||iever==10||iever==20){ if(obj.complete){ result[0] = 2; }else{ result[0] = 0; } obj1 = document.getelementbyid(inpobj); tmp = obj1.files[0].name; }else{ //娉ㄦ剰,鏈夋椂瀵逛簬鏌愪簺鍥剧墖,绯荤粺鍥炴姤鏍煎紡涓嶅鐨勯敊璇?杩欐椂鍦ㄦ煡鎵鹃敊璇墠,鍏堢敤acdsee鍙﹀瓨涓€涓?浠ラ槻姝㈡煇浜涗笉鏍囧噯鐨勫浘鐗囨牸寮? if(obj.readystate=='loading'){ result[0] = 0; }else if(obj.readystate=='uninitialized'){ result[0] = 1; }else if(obj.readystate=='complete'){ result[0] = 2; } tmp = obj.src } result[4] = tmp; } if(types==3){ result[0] = 2; tmp = imgsrc; } if(result[0]==-1) return result; if(tmp.indexof('\\')!=-1){ tmp = tmp.substring(tmp.lastindexof('\\')+1); }else if(tmp.indexof('/')!=-1){ tmp = tmp.substring(tmp.lastindexof('/')+1); } if(tmp.lastindexof('.')==-1){ result[1] = ''; }else{ str = tmp.substring(tmp.indexof('.')+1); if(str.lastindexof('.')!=-1){ result[1] = ''; }else{ result[1] = str.tolowercase(); } if(types==3){ result[2] = tmp.substring(0, tmp.indexof('.')).tolowercase()+'.'+result[1]; } } if(types==2){ if(result[0]!=2){ result[2] = 0; result[3] = 0; }else{ if(iever==8||iever==9||iever==7){ if(obj!=null){ try{ result[2] = obj.offsetwidth; result[3] = obj.offsetheight; }catch(e){ result[2] = obj.width; result[3] = obj.height; } }else{ result[2] = 0; result[3] = 0; } }else{ result[2] = obj.width; result[3] = obj.height; } } } return result; } if(types==4){ //瑙e喅鍦↖e涓棤娉曟竻绌篺ile鏂囦欢鍩熺殑瑙e喅鏂规 obj = document.getelementbyid(inpobj); if(obj.outerhtml) obj.outerhtml = obj.outerhtml; else obj.value = ''; //娓呯┖鏂囦欢涓婁紶鍩烣f(鍖呮嫭3.5) } if(types==5||types==51){ //鑼冧緥瑙丏ms鐨凱rojectadd.asp loadcomplete = false; if(document.body.addeventlistener){ if(inpobj.complete) loadcomplete = true; }else{ if(inpobj.readystate=='complete') loadcomplete = true; } if(loadcomplete){ var imgwidth, imgheight, loadcomplete imgwidth = parseint(inpobj.width); imgheight = parseint(inpobj.height); str = containerid.split('|'); currsize = [parseint(str[0]), parseint(str[1])]; if(imgwidth>=currsize[0]||imgheight>=currsize[1]){ if(currsize[0]/imgwidth>currsize[1]/imgheight){ currsize[3] = currsize[1]; currsize[2] = imgwidth*(currsize[1]/imgheight); inpobj.style.top = '0px'; if(types==5) inpobj.style.left = parseint((currsize[0]-currsize[2])/2)+'px'; }else{ currsize[2] = currsize[0]; currsize[3] = imgheight*(currsize[0]/imgwidth); inpobj.style.left = '0px'; inpobj.style.top = parseint((currsize[1]-currsize[3])/2)+'px'; } } inpobj.width = currsize[2]; inpobj.height = currsize[3]; inpobj.style.visibility = 'visible'; obj = inpobj.parentnode; if(obj!=null) obj.classlist.remove("downloadimg"); } } } function systemjudge(types){//types鐨勫惈涔?1:鍒ゆ柇ie褰撳墠鐨勫吋瀹规ā寮?5:ie鎬紓妯″紡 7,8,9:ie鏍囧噯妯″紡) 2:-1:鏋侀€熸ā寮忔垨鐏嫄 20:edge >0:ie鐗堟湰 3:濡傛灉鏄疘e鎴朎dge,涓簍rue,鍚﹀垯涓篺alse 4:杩斿洖娴忚鍣ㄥ唴鏍?灏忓啓) 5:鍒ゆ柇鏄惁鏄井淇℃祻瑙堝櫒 6:鍒ゆ柇鏄惁鏀寔flash var str, tmp, currjudge if(types==1||types==3){ currjudge = null; if(navigator.appname=='microsoft internet explorer'){ if(document.documentmode){ //documentmode灞炴€ц繑鍥炴祻瑙堝櫒娓叉煋褰撳墠鏂囨。鎵€鐢ㄧ殑妯″紡 currjudge = document.documentmode; }else{ currjudge = 5; // quirks mode unless proven otherwise if(document.compatmode){ if(document.compatmode == 'css1compat') currjudge = 7; } } } } if(types==2||types==3){ currjudge = -1; str = navigator.useragent.tolowercase(); if(str.indexof('msie')!=-1){ if(str.indexof('msie 10')!=-1||str.indexof('msie 9')!=-1||str.indexof('msie 8')!=-1||document.documentmode){//document.documentmode:闃叉ie8鐨勫吋瀹规ā寮忎笅navigator.useragent鏄剧ず涓篿e7 if(str.indexof('msie 10')!=-1){ currjudge = 10; }else if(str.indexof('msie 9')!=-1){ currjudge = 9; }else if(str.indexof('msie 7')!=-1&&document.documentmode==5){ //鍦╳in7鐨処e11涓?鏂囨。妯″紡5鍜?鏄竴鏍风殑useragent currjudge = 7; }else{ currjudge = 8; } }else if(str.indexof('msie 7')!=-1){ currjudge = 7; }else if(str.indexof('msie 6')!=-1){ currjudge = 6; }else{ currjudge = 11; } }else{ if(str.indexof('windows nt 6.1;')!=-1&&str.indexof('trident/7.0;')!=-1) currjudge = 20; } if(types==3){ if(currjudge>0) currjudge = true; else currjudge = false; } } if(types==4){ var ua = navigator.useragent.tolocalelowercase(); var currjudge=null; if(ua.match(/msie|trident/)!=null) { currjudge = 'ie'; browserversion = ua.match(/msie ([\d.]+)/) != null?ua.match(/msie ([\d.]+)/)[1]:ua.match(/rv:([\d.]+)/)[1]; }else if(ua.match(/opera/)!=null) { currjudge = 'opera'; }else if(ua.match(/applewebkit/)!=null) { currjudge = 'webkit'; //鑻规灉銆佽胺姝屽唴鏍? }else if(ua.match(/gecko|khtml/)!=null){ currjudge = 'gecko'; //鐏嫄鍐呮牳 }else if(ua.match(/applewebkit.*mobile.*/)!=null){ currjudge = 'mobile'; }else if(ua.match(/\(i[^;]+;( u;)? cpu.+mac os x/)!=null) { currjudge = 'ios'; }else if(ua.match(/android|linux/)!=null) { currjudge = 'android'; }else if(ua.match(/iphone/)!=null) { currjudge = 'iphone'; }else if(ua.match(/tencenttraveler/)!=null||ua.match(/qqbrowse/)!=null) { currjudge = 'qq'; }else if(ua.match(/ipad/)!=null){ currjudge = 'ipad'; }else if(ua.match(/chrome/)!=null){ var is360 = _mime("type", "application/vnd.chromium.remoting-viewer"); function _mime(option, value) { var mimetypes = navigator.mimetypes; for(var mt in mimetypes){ if(mimetypes[mt][option] == value){ return true; } } return false; } if(is360){ currjudge = '360'; }else{ currjudge = 'google'; } }else if(ua.match(/safari/)!=null){ currjudge = 'safari'; } } if(types==5){ str = navigator.useragent.tolowercase(); currjudge = str.indexof('micromessenger')!=-1; } if(types==6){ currjudge = false; str = navigator.useragent.tolowercase(); if(str.indexof('msie')!=-1||(str.indexof('windows nt 6.1;')!=-1&&str.indexof('trident/7.0;')!=-1)){ try{ tmp = new activexobject('shockwaveflash.shockwaveflash'); currjudge = true; }catch(e){} }else{ try{ tmp = navigator.plugins['shockwave flash']; if(typeof swf2!='undefined') currjudge = true; }catch(e){} } } return currjudge; }