madsovenielsen Posted August 19, 2009 Share Posted August 19, 2009 Hey all. i ran a script through JSlint and got an error: Implied global document line 7 document.getElementById("imageGallery").style.backgroundImage="url("+auditt_gallery[picref]+")"; Why ?/mads Link to comment Share on other sites More sharing options...
jeffman Posted August 19, 2009 Share Posted August 19, 2009 Go to the horse's mouthhttp://www.jslint.com/lint.htmlunder Global Variables Link to comment Share on other sites More sharing options...
madsovenielsen Posted August 19, 2009 Author Share Posted August 19, 2009 Go to the horse's mouthhttp://www.jslint.com/lint.htmlunder Global VariablesI Dident know that document was a variable.... Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2009 Share Posted August 19, 2009 What did you think it was? Link to comment Share on other sites More sharing options...
madsovenielsen Posted August 19, 2009 Author Share Posted August 19, 2009 What did you think it was?I really dont know... how do i make document. local ? putting it in a local variable ? what is the best way ??/mads Link to comment Share on other sites More sharing options...
Ingolme Posted August 19, 2009 Share Posted August 19, 2009 I really dont know... how do i make document. local ? putting it in a local variable ? what is the best way ??/madsIf you made it local, it wouldn't have the getElementById() method. You actually do want your document variable to be global.If you really did want to make a local document variable, you would use the var keyword:var document = new Object(); Link to comment Share on other sites More sharing options...
madsovenielsen Posted August 19, 2009 Author Share Posted August 19, 2009 If you made it local, it wouldn't have the getElementById() method. You actually do want your document variable to be global.If you really did want to make a local document variable, you would use the var keyword:var document = new Object(); Okay. i understand. but why does JSlint think having a global document. is an error ?to avoid name collisions ?/mads Link to comment Share on other sites More sharing options...
Ingolme Posted August 19, 2009 Share Posted August 19, 2009 I really don't think it's an error. I think it's just a notice. Select "Assume a browser" in the options before validating your code. Link to comment Share on other sites More sharing options...
madsovenielsen Posted August 19, 2009 Author Share Posted August 19, 2009 I really don't think it's an error. I think it's just a notice. Select "Assume a browser" in the options before validating your code.Okay. thanks. appriciate it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.