IE浏览器问题

时间:2011-08-25 16:23:07

标签: c# javascript jquery asp.net html

我正在创建一个LI并使用JQUERY代码将其附加到UL。

     listHtml = "<li id='ordli' whereaboutid='' action='Insert' onthefly='True' class='myDragClass'>" +
    "<div class='orderBox'>" +
    "<span><a href='#' id='114' title='delete' class='itemOrderDelete'>X</a></span></div>" +
    "</li>";

$(this).append(listHtml);

问题是,IE使用页面网址而不是#来呈现 href

In Firefox 

<a href='#' id='114' title='delete' class='itemOrderDelete'>X</a>

This is correct

But in IE (Compatibility mode)

<a href='http://localhost:1224/pages/index.aspx#' id='114' title='delete' class='itemOrderDelete'>X</a>

This is incorrect

知道为什么URL会附加在HREF中。如何消除它?提前谢谢。

1 个答案:

答案 0 :(得分:0)

是的,IE9在兼容IE9时会发生这种情况,你可以尝试这个修复:

FOR TEST

HTML:

JS

var listHtml = $('<li id="ordli" whereaboutid="" action="Insert" onthefly="True" class="myDragClass"> \
    <div class="orderBox"> \
    <span><a href="" id="114" title="delete" class="itemOrderDelete">X</a></span></div> \
    </li>');

$(listHtml).find('a').attr('href', '#');

$('ul').append(listHtml);

alert($('ul').html());

test