You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
899 B
38 lines
899 B
8 years ago
|
var addUrlParam = function (url, key, val) {
|
||
|
var newParam = encodeURIComponent(key) + '=' + encodeURIComponent(val);
|
||
|
|
||
|
url = url.split('#')[0];
|
||
8 years ago
|
var twoPart = url.split('?'), params = {};
|
||
|
var tmp = twoPart[1] ? twoPart[1].split('&') : [];
|
||
6 years ago
|
for (var i in tmp) {
|
||
|
var a = tmp[i].split('=');
|
||
8 years ago
|
params[a[0]] = a[1];
|
||
|
}
|
||
|
|
||
|
params[key] = val;
|
||
|
|
||
|
url = twoPart[0] + '?';
|
||
6 years ago
|
for (var key2 in params) {
|
||
7 years ago
|
url += encodeURIComponent(key2) + '=' + encodeURIComponent(params[key2]) + '&';
|
||
8 years ago
|
}
|
||
|
|
||
|
url = url.substring(0, url.length - 1);
|
||
8 years ago
|
|
||
|
return url;
|
||
|
};
|
||
|
|
||
8 years ago
|
$(function () {
|
||
8 years ago
|
$(document).on('click', 'a[href-post]', function (e) {
|
||
8 years ago
|
e.preventDefault();
|
||
|
|
||
|
var form = document.createElement('form');
|
||
|
form.style.display = 'none';
|
||
|
form.method = 'post';
|
||
|
form.action = $(this).attr('href-post');
|
||
|
form.target = '_self';
|
||
8 years ago
|
|
||
8 years ago
|
document.body.appendChild(form);
|
||
|
form.submit();
|
||
|
});
|
||
|
});
|