Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.onload and setInterval()

Status
Not open for further replies.

Andrew1985

Programmer
Joined
Feb 27, 2006
Messages
3
Location
CA
How can I get this to work? I want to create a function that counts down from two sections, executes a function and cuts itself off.

It seems that anywhere i put setInterval inside these functions it keeps daying that the function doesn't exist.

So basically what i'm asking is how can i get the below script to work?

Thanks!

<script type="text/javascript">
function init ()
{
function alertHello ()
{
alert('hello');
}
alertHello();
}
window.onload = init;
</script>

 
Code:
<script type="text/javascript">
function init () {
    alertHello();
}

function alertHello () {
    alert('hello');
}

window.onload = init;
</script>



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
you want it to wait two seconds before alerting hello?

do this:

Code:
<script type="text/javascript">
function init () {
    alertHello();
}

function alertHello () {
    alert('hello');
}

window.onload = function() { setTimeout( "init()", 2000 ) };
</script>



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top