简体   繁体   中英

jQuery 1.3.2 adds sizset='' sizcache='' attributes on IE when I use .html() function

When I do $('div#tborder').html() I get following:

<DIV id=tborder style="BORDER-RIGHT: #000 1px solid; BORDER-TOP: #000 1px solid; 
DISPLAY: block; FONT-SIZE: 12px; BORDER-LEFT: #000 1px solid; 
BORDER-BOTTOM: #000 1px solid; FONT-FAMILY: Arial; 
TEXT-ALIGN: left" sizcache="9" sizset="124">Some Text </div>

See the additional sizcache and sizset attributes are set. How can I get rid of these? This is a known bug in jQuery1.3.2 according to this . Please see the comments in this article as well.

Original Code:

<DIV id=tborder style="BORDER: #000 1px solid;  
DISPLAY: block; FONT-SIZE: 12px; FONT-FAMILY: Arial; 
TEXT-ALIGN: left">Some Text </div>

Do you really need to use html? It seems to return a lot of useless attributes along with sizcache and sizset. If all you want is the text, then have a look at text() instead.

Put quotation marks around the id value. id=tborder -> id="tborder"
Also make both div lower case. <DIV> </div> -> <div></div>

If those two things don't work. Then use removeAttr().html() .

$( "#tborder" ).removeAttr("sizcache").removeAttr( "sizset" ).html();

虽然不是很好的解决方案,但我已经使用javascript RegExp函数暂时将其破解。

If you have a javascript error in your page, you will see these do not always get removed by the sizzle engine. For instance, if you put a reference to a method/function in the window opener pages javascript function, and you did not open the page from that opener, you will see these.

for instance in this code, the opener is not present:

if (self.opener.panelNotes)
{
    self.opener.__doPostBack("panelNotes", "");
};

because I directly opened the window, and it was not opened by another window so no opener exists. This gives a javascript error on the page

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; MDDR; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0) Timestamp: Thu, 6 May 2010 15:15:16 UTC

Message: 'self.opener.panelNotes' is null or not an object Line: 278 Char: 9 Code: 0 URI: http://localhost/prototype/Apps/SmartPrototype/Js/MarkPrototype.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM