Google Answers Logo
View Question
 
Q: run javascript on page load ( No Answer,   8 Comments )
Question  
Subject: run javascript on page load
Category: Computers
Asked by: deathland-ga
List Price: $2.00
Posted: 03 Jan 2006 22:14 PST
Expires: 02 Feb 2006 22:14 PST
Question ID: 428814
How to run javascript on page load?
Answer  
There is no answer at this time.

Comments  
Subject: Re: run javascript on page load
From: document123-ga on 04 Jan 2006 03:04 PST
 
You need add an OnLoad event to the HTML body tag.

This URL should help.

http://www.htmlcodetutorial.com/document/index_attsupp_1.html
Subject: Re: run javascript on page load
From: larkas-ga on 05 Jan 2006 00:21 PST
 
Do you have access to make changes to the page source on the server?

If so, add an onload event.

If you do not have access and still want to run Javascript when the
page loads locally, you should use the Greasemonkey extension in
Firefox or something like it in IE (see:
http://greasemonkey.mozdev.org (Firefox)
http://www.daishar.com/blog/archives/2005/03/greasemonkey_fo.html
(IE))
Subject: Re: run javascript on page load
From: vijaypangam-ga on 09 Jan 2006 03:20 PST
 
in the body take use onload event
eg. <body onload="yourfunction()">
Subject: Re: run javascript on page load
From: vijaypangam-ga on 09 Jan 2006 03:20 PST
 
in the body tag use onload event
eg. <body onload="yourfunction()">
Subject: run javascript on page load
From: matiasbaruchinsaurra-ga on 13 Jan 2006 15:48 PST
 
You must write directly, like:
<script>
your script
</script>
so it will load directly when the page loads.
But if you put:
<script>
function (name)
your script
</script>
so you must put a button for example.
onClick="function(name)"
I wish my HELP HELPS YOU!
Subject: Re: run javascript on page load
From: idani-ga on 13 Jan 2006 18:37 PST
 
Running JS on page load is simple.

onload event on body tags will do the trick.
exmple: <body onload="alert('Hello!');">

You can use onunload events and onbeforeunload to get JS run on page unloaded.

More information at:
http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onload.asp
Subject: Re: run javascript on page load
From: quinny61994-ga on 14 Jan 2006 08:00 PST
 
If you want to use Javascript in...

Microsoft Word/Frontpage - You can use macros in the script processor
by going to Tools>Macro>Microsoft Script Editor.  That should work.

Free Webhost - Webhosts will usually have a clear tab at the top of
the page editor that says either "Plain Text" or "HTML".  Click on
HTML and copy/paste your javascript.  In Freewebs.com you have to
click on the button on the toolbar in webs edit that looks like this :
< >  ... and when you click it it says type your custom HTML code in
here.


Thanks,

Quinny61994
Subject: Re: run javascript on page load
From: kriskatakam-ga on 24 Jan 2006 22:34 PST
 
Hi this the way you can run a script when a page gets loaded

<html>

<head>

<script language="javascript">

function funcToCall()

{

    alert('called');

}

</script>

</head>

 

<body onload="funcToCall()">

 

</body>

 

</html>

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy