This is probably the beginning of many questions to e. I have finished building my site and I was using Firefox to view and test the site. I am now IE fixing and am stuck at the first JavaScript error which only IE seems to be throwing a hissy about. I run the IE 8 JavaScript debugger and get this:
Object doesn't support this property or method app.js, line 1 character 1
Source of app.js (first 5 lines):
var menu = {};
menu.current = "";
menu.first = true;
menu.titleBase = "";
menu.init = function(){...
I have tested the site in a Webkit browser and it works fine in that. What can I do to fix this? The site is pretty jQuery intensive so i have given up any hope for getting it to work in IE6 but I would appreciate it working in all the others.
UPDATE: I have upload the latest version of my site to
This is probably the beginning of many questions to e. I have finished building my site and I was using Firefox to view and test the site. I am now IE fixing and am stuck at the first JavaScript error which only IE seems to be throwing a hissy about. I run the IE 8 JavaScript debugger and get this:
Object doesn't support this property or method app.js, line 1 character 1
Source of app.js (first 5 lines):
var menu = {};
menu.current = "";
menu.first = true;
menu.titleBase = "";
menu.init = function(){...
I have tested the site in a Webkit browser and it works fine in that. What can I do to fix this? The site is pretty jQuery intensive so i have given up any hope for getting it to work in IE6 but I would appreciate it working in all the others.
UPDATE: I have upload the latest version of my site to http://www.frankychanyau.
Share Improve this question edited Jun 10, 2011 at 2:42 Franky Chanyau asked Jun 10, 2011 at 2:09 Franky ChanyauFranky Chanyau 1,0101 gold badge15 silver badges24 bronze badges 6- Its reporting the wrong line i think. You'll have to show more code. – James Khoury Commented Jun 10, 2011 at 2:12
- Can you provide a live/test/working example of the reproducable error? What you have there shouldn't error at that point. you can build an example on jsFiddle – Alastair Pitts Commented Jun 10, 2011 at 2:12
- 2 IE's error messages are notoriously cryptic, though they can be deciphered with some effort. They often report an error well before the actual error, you'll need to show more code or post an example on jsFiddle or wherever. You may have an extra trailing ma in an object or array literal. – RobG Commented Jun 10, 2011 at 2:24
- Agreed that what you are showing should not cause any errors. We would need something more to look at. – Funka Commented Jun 10, 2011 at 2:27
- I thought it would be faster if I just uploaded a version of the site to my server. The link is in the question – Franky Chanyau Commented Jun 10, 2011 at 2:43
3 Answers
Reset to default 3In IE8, your code is causing jQuery to fail on this line
$("title").text(title);
in the menu.updateTitle() function. Doing a bit of research (i.e. searching with Google), it seems that you might have to use document.title
with IE.
Your issue is (probably) here:
menu.updateTitle = function(hash){
var title = menu.titleBase + ": " + $(hash).data("title");
$("title").text(title); // IE fails on setting title property
};
I can't be bothered to track down why jQuery's text()
method fails here, but it does. In any case, it's much simpler to not use it. There is a title property of the document object that is the content of the document's title element. It isn't marked readonly, so to set its value you can simply assign a new one:
document.title = title;
and IE is happy with that.
It is a good idea to directly access DOM properties wherever possible and not use jQuery's equivalent methods. Property access is less troublesome and (very much) faster, usually with less code.
Well, your line 1 certainly looks straight forward enough. Assuming the error line and number is not erroneous, it makes me think there is a hidden character in the first spot of your js file that is throwing IE for a fit. Try opening the file in another text editor that may support display of normally hidden characters. Sometimes copying/pasting the source into a super-basic text-editor, like Notepad, can sometimes strip out non-displayable characters and then save it back into place directly from Notepad.