MySQL 数据:
http%3A//www.yourname.com/path/%3FdisplayClick%23demo
(http://www.yourname.com/path/?testID#test)
我使用了“decodeURI”但不起作用..
Javascipt 代码:
$.fn.saveClicks = function() {
$(this).bind('mousedown.clickmap', function(evt) {
$.post('http://www.yourname.com/path/file.php', {
x:evt.pageX,
y:evt.pageY,
l:escape(document.location)
});
});
};
对于网址:
document.location
如何清理网址?
最佳答案
$.post('http://www.yourname.com/path/file.php', {
…,
l:escape(document.location)
});
当您将数据作为对象传递时,jQuery 会自动对您发送的数据进行 URL 编码。这里不需要escape()
任何东西。这也将使您不必 unescape()
您实际想要使用它的 url。
那就这样吧
$.post('http://www.yourname.com/path/file.php', {
x: evt.pageX,
y: evt.pageY,
l: document.location.href
});
关于javascript - 我怎样才能用javascript解码URI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23504082/