先看看我们之前修改过的这个解决方案:
- var aid = 1;
- var attachexts = new Array();
- var attachwh = new Array();
- var insertType = 1;
- var thumbwidth = parseInt(60);
- var thumbheight = parseInt(60);
- var extensions = 'jpg,gif,png';
- var forms;
- var nowUid = 0;
- var albumid = 0;
- var uploadStat = 0;
- var picid = 0;
- var upid = 0;
- var mainForm;
- var successState = false;
- var lang = new Array();
- var ieVersion = userAgent.substr(userAgent.indexOf('msie') + 5, 3);
- lang['post_attachment_ext_notallowed'] = '对不起,不支持上传此类扩展名的文件。';
- lang['post_attachment_deletelink'] = '删除';
- lang['post_attachment_insert'] = '点击这里插入内容中当前光标的位置';
- lang['post_attachment_insertlink'] = '插入';
- lang['need_ie'] = '对不起,请在IE浏览器下面使用本功能';
- lang['post_size_nofix_width'] = '对不起,图片的宽度不能小于200像素';
- lang['post_size_nofix_height'] = '对不起,图片的高度不能小于200像素';
- function delAttach(id) {
- $('attachbody').removeChild($('attach_' + id).parentNode.parentNode.parentNode);
- if($('attachbody').innerHTML == '') {
- addAttach();
- }
- $('localimgpreview_' + id + '_menu') ? document.body.removeChild($('localimgpreview_' + id + '_menu')) : null;
- }
- function addAttach() {
- newnode = $('attachbodyhidden').rows[0].cloneNode(true);
- var id = aid;
- var tags;
- tags = newnode.getElementsByTagName('form');
- for(i in tags) {
- if(tags.id == 'upload') {
- tags.id = 'upload_' + id;
- }
- }
- tags = newnode.getElementsByTagName('input');
- for(i in tags) {
- if(tags.name == 'attach') {
- tags.id = 'attach_' + id;
- tags.name = 'attach';
- tags.onchange = function() {insertAttach(id),picshow(this,id)};
- tags.unselectable = 'on';
- }
- if(tags.id == 'albumid') {
- tags.id = 'albumid_' + id;
- }
- }
- tags = newnode.getElementsByTagName('span');
- for(i in tags) {
- if(tags.id == 'localfile') {
- tags.id = 'localfile_' + id;
- }
- }
- aid++;
- $('attachbody').appendChild(newnode);
- }
- addAttach();
- function prepice(s){
- $('img_hidden').filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = s;
- imgwidth = $('img_hidden').offsetWidth;
- imgheight = $('img_hidden').offsetHeight;
- if(imgwidth < 200) {
- alert(lang['post_size_nofix_width']);
- retur;
- }else if(imgheight < 200){
- alert(lang['post_size_nofix_height']);
- die();
- }
- }
- function picshow(imgFile,id)
- {
- //新的预览代码,支持 IE6、IE7。
- var newPreview = document.getElementById("newPreview"+id);
- newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
- newPreview.style.width = "85px";
- newPreview.style.height = "74px";
- newPreview.style.border = "2px solid green";
- }
- function insertAttach(id) {
- var localimgpreview = '';
- var path = $('attach_' + id).value;
- var ext = getExt(path);
- var re = new RegExp("(^|\\s|,)" + ext + "($|\\s|,)", "ig");
- var localfile = $('attach_' + id).value.substr($('attach_' + id).value.replace(/\\/g, '/').lastIndexOf('/') + 1);
- if(path == '') {
- return;
- }
- prepice(path);
- // alert('012eedddee');
- var extensionss = 'jpg,gif,png';
- if(extensionss != '' && (re.exec(extensionss) == null || ext == '')) {
- alert(lang['post_attachment_ext_notallowed']);
- return;
- }
- attachexts[id] = inArray(ext, ['gif', 'jpg', 'png']) ? 2 : 1;
- var $inhtml = '<table cellspacing="2" cellpadding="2">';
- if(is_ie && ieVersion < 7.0) {
- $inhtml += '<tr><td><img src="' + $('attach_' + id).value+'" style="border:2px solid green" width="85" height="74"></td>';
- } else {
- $inhtml += '<tr><td><div id="newPreview'+ id +'" style="width:60px;height:80px;filter:progidXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);"></div></td>';
- }
- $inhtml += '<td><span id="showmsg'+ id +'" style="float:right;"><a href="javascript:;" onclick="delAttach('+ id +')">[' + lang['post_attachment_deletelink'] + ']</a></span>图片描述:<br/><textarea name="pic_title" id="pic_title" cols="40" style="width:365px;" rows="3"></textarea><br><input '+ hiddsa +' id="ptypea'+ id +'" name="ptype" value="48"><font '+ hidda +'><label for="ptypea'+ id +'">房型图 </label></font><input '+ hiddsb +' id="ptypeb'+ id +'" name="ptype" value="59"><font '+ hiddb +'><label for="ptypeb'+ id +'">室内照片 </label></font><input '+ hiddsc +' id="ptypec'+ id +'" name="ptype" value="11" checked><font '+ hiddc +'><label for="ptypec'+ id +'">外观景观 </label></font><input '+ hiddsd +' id="ptyped'+ id +'" name="ptype" value="10"><font '+ hiddd +'><label for="ptyped'+ id +'">会所照片 </label></font><input '+ hiddse +' id="ptypee'+ id +'" name="ptype" value="49"><font '+ hidde +'><label for="ptypee'+ id +'">样板房 </label></font>'+ hiddsf + hiddsg;
- $inhtml += '</td><td><input type="hidden" name="allowpic" value="1"></td></tr></table>';
-
- $('localfile_' + id).innerHTML = $inhtml;
- $('attach_' + id).style.display = 'none';
-
- addAttach();
- $('postbox').scrollTop = $('postbox').scrollHeight;
- }
- function inArray(needle, haystack) {
- if(typeof needle == 'string') {
- for(var i in haystack) {
- if(haystack == needle) {
- return true;
- }
- }
- }
- return false;
- }
- function insertAttachimgTag(id) {
- if(insertType == 0) {
- insertImage(id);
- } else if(is_ie) {
- edit_insert('<img id="_uchome_localimg_' + id + '" src="' + $('attach_' + id).value + '">');
- } else {
- alert(lang['need_ie']);
- }
- }
- function uploadSubmit(obj) {
- obj.disabled = true;
- mainForm = obj.form;
- forms = $('attachbody').getElementsByTagName("FORM");
- albumid = $('uploadalbum').value;
- upload();
- }
- //上传页面
- function start_upload() {
- $('btnupload').disabled = true;
- mainForm = $('albumresultform');
- forms = $('attachbody').getElementsByTagName("FORM");
- upload();
- }
- function upload() {
- if(typeof(forms[nowUid]) == 'undefined') return false;
- var nid = forms[nowUid].id.split('_');
- nid = nid[1];
- if(nowUid>0) {
- var upobj = $('showmsg'+upid);
- //alert(nowUid);
- if(uploadStat==1) {
- upobj.innerHTML = '<font color="green">上传成功</font>';
- successState = true;
- var InputNode;
- //两种生成方式,解决浏览器之间的兼容性问题
- try {
- //IE模式下的创建方式,解决常规setAttribute设置属性带来的一些未知的错误
- var InputNode = document.createElement("<input type="hidden" id="picid_" + picid + "" value=""+ upid +"" name="picids["+picid+"]">");
- } catch(e) {
- //非IE模式则须要用下列的常规setAttribute设置属性,否则生成的结果不能正常初始化
- var InputNode = document.createElement("input");
- InputNode.setAttribute("name", "picids["+picid+"]");
- InputNode.setAttribute("type", "hidden");
- InputNode.setAttribute("id", "picid_" + picid);
- InputNode.setAttribute("value", upid);
- }
- mainForm.appendChild(InputNode);
- } else {
- upobj.style.color = "#f00";
- upobj.style.fontweight = "bold";
- upobj.innerHTML = '上传失败:'+uploadStat;
- }
- }
- if($('showmsg'+nid) != null) {
- $('showmsg'+nid).innerHTML = '上传中,请等待...';
- $('albumid_'+nid).value = albumid;
- forms[nowUid].submit();
- } else if(nowUid+1 == forms.length) {
- if(typeof (no_insert) != 'undefined') {
- var albumidcheck = parseInt(parent.albumid);
- $('opalbumid').value = isNaN(albumidcheck)? 0 : albumid;
- if(!successState) return false;
- }
- showstopic();
- }
-
- upid = nid;
- nowUid++;
- uploadStat = 0;
- }
- /**
- * 无刷新定义
- * author Minko
- */
- function Get_AJAX(){var ajax=false;try{ajax=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{ajax=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){ajax=false;}}if(!ajax && typeof XMLHttpRequest != 'undefined'){ajax=new XMLHttpRequest();}return ajax;}function loadXMLDoc(data){var xmlDoc;if(window.ActiveXObject){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");}else if (document.implementation && document.implementation.createDocument){xmlDoc=document.implementation.createDocument("","",null);}else{alert('Your browser cannot handle this script');}xmlDoc.async=false;xmlDoc.preserveWhiteSpace= true;xmlDoc.load(data)||xmlDoc.loadXML(data);return xmlDoc;}
-
- var minko=null;
- var ajax = Get_AJAX(); // 定义无刷新
- function showstopic(){
- ajax.open("GET","storeselect_ajax.php?uid="+uidm+'&hotmid=' + mid + '&maxtime=' + maxtime,true);
- ajax.onreadystatechange =function(){doResponsee () };
- ajax.send(null);
- }
- function doResponsee(){
- if(ajax.readyState == 4){
- if(ajax.status == 200){
- var ResponseDOM = ajax.responseText;
- minko = ResponseDOM;
- $(showpicsid).innerHTML = minko;
- }
- }
- }
复制代码
在各个浏览器里测试关于图片上传页的情况,都有图了,对比一下
这个页面里的(左侧的上传链接) http://u.discuz.net/home/cp.php?ac=upload
IE6 图片上传页,完全正常
IE7 图片上传页,没有图片预览,两张图片以上浏览按钮循环出现
IE8 图片上传页,没有图片预览,两张图片以上浏览按钮没有循环出现
火狐3.5 图片上传页,没有图片预览,两张图片以上浏览按钮没有循环出现
谷歌 图片上传页,没有图片预览,两张图片以上浏览按钮没有循环出现,但是跟其他浏览器有点不一样
safari 图片上传页,没有图片预览,两张图片以上浏览按钮没有循环出现,但是跟其他浏览器有点不一样
opera 图片上传页,没有图片预览,两张图片以上浏览按钮没有循环出现 |