if(!(window.jQuery)) { var s = document.createElement('script'); s.setAttribute('src', '//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'); s.setAttribute('type', 'text/javascript'); document.getElementsByTagName('head')[0].appendChild(s); } if(window.addEventListener){ window.addEventListener("load",jhcload,false); } else{ window.attachEvent("onload",jhcload); } function jhcload(){ $(function(){ huiyuan(); }); } function huiyuan(){ var yoururl=$(".tags:contains('加入收藏')").prop('href'); var data=getQueryObject(yoururl); var url="/e/extend/zdfw/index.php"; $.post(url,data,function(r){ if(r=='1')return false; $("#pages").remove(); $('.content').html(r); },"html"); return false; } function getQueryObject(url) { url = url === null ? window.location.href : url; var search = url.substring(url.lastIndexOf("?") + 1); var obj = {}; var reg = /([^?&=]+)=([^?&=]*)/g; search.replace(reg, function (rs, $1, $2) { var name = decodeURIComponent($1); var val = decodeURIComponent($2); val = String(val); obj[name] = val; // return rs; console.log(rs); }); return obj; }
js获取地址里的参数,post数据,jquery
$("body").on({
"dragenter": function (e) {
e.preventDefault();
//格式显示
$('.word2html').css({'border':'2px dashed red','line-height':'300px'});
},
"dragover": function (e) {
e.preventDefault();
},
"drop": function (e) {
$('.word2html').css({'border':'0px','line-height':'50px'});
if($(e.target).is(".word2html")){
e.preventDefault();
let file = e.originalEvent.dataTransfer.files;
$("#fileToUpload").prop("files",file);
}
}
});
以上代码,实现拖拽上传后,判断是否目标元素。如果是,就执行。