Reputation: 3256
I am using jquery_and_timers.js. But when i try to run my webpage. It gives following error: Line: 16 Error: 'body' is null or not an object
Here is the error line:
return Math.max(f.documentElement["client" + c], f.body["scroll" + c], f.documentElement["scroll" + c], f.body["offset" + c], f.documentElement["offset" + c])
Can anyone tell how to fix this?
** I think this is where it is happening: I call a method
loadIframe() from $(document).ready(function () {...
function loadIFrame() {
$("#toggleStyle").attr("href", "style/la.css");
$('#Src').insertBefore('#togg');
$("#inf").attr("src", "images/inf.png");
}
It is when this method loadIframe is called it gives that error.
Upvotes: 0
Views: 3028
Reputation:
There's really not enough code in your question, but since the error is about body
, and not about documentElement
, I'm guessing f
is document
, and you're running the code before the DOM is ready.
You can run the code after the DOM is ready by placing it in a handler passed to jQuery's .ready()
method.
$(document).ready(function() {
// your code
});
Or if in spite of the jQuery tag you're not using jQuery, just place your script just before the closing </body>
tag...
<body>
<!-- your HTML -->
<script>
// your script
</script>
</body>
Upvotes: 2
Reputation: 324750
Is this code being called in the <head>
of your document? If so, the body doesn't exist yet.
Upvotes: 1