博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个问题提交的实例(js原生动画,原生ajax,js引用加参数)
阅读量:7108 次
发布时间:2019-06-28

本文共 6585 字,大约阅读时间需要 21 分钟。

document.writeln("
");document.writeln("

请您留言

");document.writeln("
打开
");document.writeln("
");document.writeln("
");document.writeln("

请您留言

");document.writeln("
关闭
");document.writeln("
");document.writeln("
");document.writeln("
类型");document.writeln("
");document.writeln("
");document.writeln("
姓名");document.writeln("
");document.writeln("
");document.writeln("
电话");document.writeln("
");document.writeln("
");document.writeln("
");document.writeln("
");document.writeln("
");var url = "XXX";var par;var a = document.getElementById("tanchuangwai");var b = document.getElementById("guanbi");var p; var s;var h;function goPanel(){ document.getElementById("tanchuangwai").style.display = "none"; p = document.getElementById("tanchuang"); p.style.display = "block"; p.style.height = "29px"; s = setInterval(upPanel,1);}function goClose(){ p = document.getElementById("tanchuang"); h = setInterval(downPanel,1);}function upPanel(){ var height = parseInt(p.style.height.replace("px","")); height = height + 3; p.style.height = height+"px"; if(height >= 281){ clearInterval(s); }}function downPanel(){ var height = parseInt(p.style.height.replace("px","")); height = height - 3; p.style.height = height+"px"; if(height <= 29){ clearInterval(h); p.style.display = "none"; document.getElementById("tanchuangwai").style.display = "block"; }}function ajax(){ var oAjax = null; if(window.XMLHttpRequest){ oAjax = new XMLHttpRequest(); }else{ oAjax = new ActiveXObject("Microsoft.XMLHTTP"); }; oAjax.open('POST', url, true); oAjax.setRequestHeader("Content-type","application/x-www-form-urlencoded"); var area = document.getElementById("pArea").value; var sel = document.getElementById("pSel").value; var name = document.getElementById("pName").value; var tel = document.getElementById("pTel").value; var url1 = window.location.href; oAjax.send("area=" + area + "&sel=" + sel + "&name=" + name + "&tel=" + tel + "&par=" + par + "&url=" + url1); oAjax.onreadystatechange = function(){ if(oAjax.readyState == 4){ if(oAjax.status == 200){ alert(oAjax.responseText) }else{ alert("请求错误"); } } };}function sub() { var js = document.getElementsByTagName("script"); for (var i = 0; i < js.length; i++) { if (js[i].src.indexOf("panel.min.js") >= 0) { var arraytemp = new Array(); arraytemp = js[i].src.split('?'); arraytemp = arraytemp[1].split('='); if (arraytemp[0] == 'value') { par = arraytemp[1]; } } }; ajax();}

 同样的代码,这是修改后的使用ajax上传图片的代码:

var url = "http://XXX";document.writeln("
");document.writeln("

请您留言

");document.writeln("
打开
");document.writeln("
");document.writeln("
");document.writeln("

请您留言

");document.writeln("
关闭
");document.writeln("
");document.writeln("
");document.writeln("
类型");document.writeln("
");document.writeln("
");document.writeln("
姓名");document.writeln("
");document.writeln("
");document.writeln("
电话");document.writeln("
");document.writeln("
");document.writeln("
上传");document.writeln("
");document.writeln("
");document.writeln("
");document.writeln("
");document.writeln("
");document.writeln("");var par;var upload = "WebForm3.aspx";var a = document.getElementById("tanchuangwai");var b = document.getElementById("guanbi");var p; var s;var h;var scs;function goPanel(){ document.getElementById("tanchuangwai").style.display = "none"; p = document.getElementById("tanchuang"); p.style.display = "block"; p.style.height = "28px"; s = setInterval(upPanel,1);}function goClose(){ p = document.getElementById("tanchuang"); h = setInterval(downPanel,1);}function upPanel(){ var height = parseInt(p.style.height.replace("px","")); height = height + 3; p.style.height = height+"px"; if(height >= 313){ clearInterval(s); }}function downPanel(){ var height = parseInt(p.style.height.replace("px","")); height = height - 3; p.style.height = height+"px"; if(height <= 29){ clearInterval(h); p.style.display = "none"; document.getElementById("tanchuangwai").style.display = "block"; }}function ajax(){ var oAjax = null; if(window.XMLHttpRequest){ oAjax = new XMLHttpRequest(); }else{ oAjax = new ActiveXObject("Microsoft.XMLHTTP"); }; oAjax.open('POST', url, true); var area = document.getElementById("pArea").value; var sel = document.getElementById("pSel").value; var name = document.getElementById("pName").value; var tel = document.getElementById("pTel").value; var url1 = window.location.href; var fd = new FormData(); fd.append('area', area); fd.append('sel', sel); fd.append('name', name); fd.append('tel', tel); fd.append('par', par); fd.append('url', url1); fd.append("img", document.getElementById("img").files[0]); oAjax.send(fd); oAjax.onreadystatechange = function(){ if(oAjax.readyState == 4){ if(oAjax.status == 200){ alert(oAjax.responseText) }else{ alert("请求错误"); } } };}function sub() { var js = document.getElementsByTagName("script"); for (var i = 0; i < js.length; i++) { if (js[i].src.indexOf("panel.js") >= 0) { var arraytemp = new Array(); arraytemp = js[i].src.split('?'); arraytemp = arraytemp[1].split('='); if (arraytemp[0] == 'value') { par = arraytemp[1]; } } }; document.getElementById("par").value = par; ajax();}

 

转载于:https://www.cnblogs.com/wpcnblog/p/5486385.html

你可能感兴趣的文章
OAF中多语言的实现(转)
查看>>
用JQUERY为INPUT的TXT类型赋值及取值操作
查看>>
Labeling Balls(拓扑排序wa)
查看>>
001_各种网页错误代码解释(400.404.504等)
查看>>
设计模式——辛格尔顿(Singleton)
查看>>
MySQL忘记root密码的找回方法
查看>>
linux下使用tar命令
查看>>
js Dialog 去掉右上角的X关闭功能
查看>>
Spring aop 小例子demo
查看>>
Ambari修改主页面方法
查看>>
SolrJ总结
查看>>
CSS选择器的权重与优先规则
查看>>
jquery序列化form表单使用ajax提交后处理返回的json数据
查看>>
iOS设计模式 - 模板
查看>>
VSS Plugin配置FAQ(翻译)[转]
查看>>
javaSE之Object及hashcode等相关知识
查看>>
js 判断是否选中
查看>>
svn提交时强制注释
查看>>
ecshop 活动-》红包
查看>>
刘未鹏的博中带的技术博客链接
查看>>