Changing the title of a web page on the fly can be useful for a bunch of reasons.
Say you’re creating an app using jQuery for example and using a single page to house content which might be different depending on what action a user takes. (A recent example was an assessment page I was building for a video site. The user watches a video and then takes an assessment. The assessment questions vary based on the video they watched, but the format of the quiz is the same, so I decided to use one assessment page for all of the videos and then just change the contents dynamically. This of course includes the page title.)
So to cut a long story short, doing this in jQuery: ($(‘title’).text(var)) works in most browsers, but IE 7 and 8 throw this beauty of an error:
SCRIPT65535: Unexpected call to method or property access. jquery.min.js, line 3 character 32461
Character 32461 refers to this: ‘this.appendChild(a)’. After some research it appears that a lot of people receive this error from IE for a bunch of different reasons, not just relating to changing the page title dynamically. To avoid this error just use some straight up JavaScript instead:
document.title = var;
Thank you so much! Or I would never know what’s the problem….
Thank you so much! After many hours searching the solution to this problem you arrived like an angel…
Thanks very very much, unbelievable!