常用js代码片段

来源:互联网 发布:扇贝软件下载 编辑:程序博客网 时间:2024/04/28 18:21



function getURLParameter(name) {        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;    }    var state=getURLParameter("state");



var href = window.location.href;    var protocol = window.location.protocol;    var host = window.location.host;    var http = protocol + '//' + host;    var target = href.substring(http.length);



<a href="javascript:;" onclick="javascript:post('<%=contextPath%>/marketa/fowardEditActivity', {maId:${maId},editFlag:'edit'})" class="col000">策划</a>



function post(url, params) {    var temp = document.createElement('form');    temp.action = url;    temp.method ='post';    temp.style.display ='none';    for (var x in params) {        var opt = document.createElement('textarea');        opt.name = x;        opt.value = params[x];        temp.appendChild(opt);    }    document.body.appendChild(temp);    temp.submit();    return temp;}


0 0