在项目中,需要设置页面title 我使用jQuery('title').html()这个方法在ie8中报错 “SCRIPT65535: 意外地调用了方法或属性访问。 ”
经查询:使用document.title="title content" 代替 jQuery('title').html("title content")
以下为jQuery官网给出的解释
原文链接:http://bugs.jquery.com/ticket/5881
jQuery('title').html() returns the title (== document.title)
jQuery('title').text() is empty
jQuery('title').text('new title')
and
jQuery('title').html('new title') both raise an error:
Error: Unexpected call to method or property access.
These all work in Firefox (I'm using 3.5.7). Finally, these work better in IE, but still not quite right :(
jQuery('title').attr('text') returns document.title
jQuery('title').attr('text','new title') sets document.title properly. However, the title displayed in the browser chrome reflects the new title only in IE6. In IE7/IE8, even though the value of document.title matches the title element's 'text' attribute, the browser chrome changes only when you set document.title.