469,291 Members | 1,767 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,291 developers. It's quick & easy.

Onload and load



Hello,

the javascript I'm using is not embedded into HTML but included. When I
looking at w3schools.com it uses examples with js embedded into html.

Anyway, when I use:

function load()
{
....
}

The page gets loaded into Firefox and then it executes all statements
inside the function but in IE the function will be totally ignored!
even onload() is ignored.

How should I implement the OnLoad() event in test.js file included in
test.html?

Thanks!
Amit.

Jul 28 '06 #1
5 6567
amit said the following on 7/27/2006 8:38 PM:
>
Hello,

the javascript I'm using is not embedded into HTML but included. When I
looking at w3schools.com it uses examples with js embedded into html.

Anyway, when I use:

function load()
{
....
}

The page gets loaded into Firefox and then it executes all statements
inside the function but in IE the function will be totally ignored!
even onload() is ignored.

How should I implement the OnLoad() event in test.js file included in
test.html?
The same way you would if you included it in the HTML:

window.onload=someFunction;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 28 '06 #2

Randy Webb wrote:
amit said the following on 7/27/2006 8:38 PM:

Hello,

the javascript I'm using is not embedded into HTML but included. When I
looking at w3schools.com it uses examples with js embedded into html.

Anyway, when I use:

function load()
{
....
}

The page gets loaded into Firefox and then it executes all statements
inside the function but in IE the function will be totally ignored!
even onload() is ignored.

How should I implement the OnLoad() event in test.js file included in
test.html?

The same way you would if you included it in the HTML:

window.onload=someFunction;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Hi Randy

I'm confused! in html we could have:

<html>
<head>
<script type="javascript">
function load()
{
alert("page is loaded ...");
}
</script>

</head>
<body onload="load()">
</body>
</html>

right? now where I should put the "onload="load()" in my code? where
should I call the function?
Thanks.
Amit

Jul 28 '06 #3
amit said the following on 7/28/2006 1:29 AM:
Randy Webb wrote:
>amit said the following on 7/27/2006 8:38 PM:
<snip>
>>How should I implement the OnLoad() event in test.js file included in
test.html?
The same way you would if you included it in the HTML:

window.onload=someFunction;

Hi Randy

I'm confused! in html we could have:
That is becoming obvious :)

Did you test the above code?
<html>
<head>
<script type="javascript">
function load()
{
alert("page is loaded ...");
}
Right here:

window.onload = load;

</script>

</head>
<body onload="load()">
Remove the onload attribute from the body tag.
right? now where I should put the "onload="load()" in my code? where
should I call the function?
You don't put onload="load()" in your external file, you give
window.onload a reference to the function you want to execute, and,
don't use the () on the window.onload statement.

window.onload = someFunctionToRunWhenTheWindowIsLoaded;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 28 '06 #4

Randy Webb wrote:
amit said the following on 7/28/2006 1:29 AM:
Randy Webb wrote:
amit said the following on 7/27/2006 8:38 PM:

<snip>
>How should I implement the OnLoad() event in test.js file included in
test.html?
The same way you would if you included it in the HTML:

window.onload=someFunction;
Hi Randy

I'm confused! in html we could have:

That is becoming obvious :)

Did you test the above code?
<html>
<head>
<script type="javascript">
function load()
{
alert("page is loaded ...");
}

Right here:

window.onload = load;

</script>

</head>
<body onload="load()">

Remove the onload attribute from the body tag.
right? now where I should put the "onload="load()" in my code? where
should I call the function?

You don't put onload="load()" in your external file, you give
window.onload a reference to the function you want to execute, and,
don't use the () on the window.onload statement.

window.onload = someFunctionToRunWhenTheWindowIsLoaded;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


I followed your steps but nothing works! I haven't got rest since
yesterday maybe later but thanks.

Jul 28 '06 #5

amit wrote:
Randy Webb wrote:
amit said the following on 7/28/2006 1:29 AM:
Randy Webb wrote:
>amit said the following on 7/27/2006 8:38 PM:
<snip>
>>How should I implement the OnLoad() event in test.js file included in
>>test.html?
>The same way you would if you included it in the HTML:
>>
>window.onload=someFunction;
>>
>
Hi Randy
>
I'm confused! in html we could have:
That is becoming obvious :)

Did you test the above code?
<html>
<head>
<script type="javascript">
function load()
{
alert("page is loaded ...");
}
Right here:

window.onload = load;

</script>
>
</head>
<body onload="load()">
Remove the onload attribute from the body tag.
right? now where I should put the "onload="load()" in my code? where
should I call the function?
You don't put onload="load()" in your external file, you give
window.onload a reference to the function you want to execute, and,
don't use the () on the window.onload statement.

window.onload = someFunctionToRunWhenTheWindowIsLoaded;

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/



I followed your steps but nothing works! I haven't got rest since
yesterday maybe later but thanks.

Ok, now it is working. last night I was too tired!

Jul 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by berg | last post: by
1 post views Thread by jake_allen_no_spam | last post: by
3 posts views Thread by Christian | last post: by
3 posts views Thread by Cc | last post: by
7 posts views Thread by marco | last post: by
5 posts views Thread by tuxedo | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.