使用jQuery地址我設置我的HREF鏈接,像這樣:無法設置與jQuery的地址在IE中正確HREF鏈接
<a href="#view_profile=123">view 123</a>
當調用我的地址更改事件:
$.address.change(function(e) {
alert(e.value);
});
我見FF和Chrome的值如我所料:
/view_profile=123
但是,IE會返回帶有前面的「/」的完整URL路徑,如下所示:
/http://localhost/#view_profile=123
任何想法爲什麼IE做到這一點,什麼是解決它的最好方法?我嘗試了幾件事,但每次都是一樣的。
下面是我用得到的鏈接路徑代碼:
// Setup jQuery address on some elements
$('a').address();
// Run some code on initial load
$.address.init(function(e) {
// Address details can be found in the event object
});
// Handle any URL change events
$.address.change(function(e) {
alert(e.value);
var urlAux = e.value.split('=');
var page = urlAux[0];
var arg = urlAux[1];
alert("page: " + page);
alert("arg: " + arg);
if (page == "/view_profile") {
...
}
});
什麼是'e'以及它是如何與你的錨? – Phil
e是我的事件對象,並保存鏈接的值,在這種情況下, – Paul
解決方案將基於如何獲取鏈接值。你可以發佈該代碼嗎?發生這種情況的原因是,當您在IE中動態創建錨點標記時,無論您是否只爲其提供相對路徑,href屬性將始終包含絕對路徑。例如,看到這個jsfiddle。 http://jsfiddle.net/xKLKZ/ –