# Running a function onload (?)

**URL:** https://forum.kirupa.com/t/running-a-function-onload/282571
**Category:** Uncategorized
**Created:** [February 23, 2009, 8:23pm UTC](https://forum.kirupa.com/t/running-a-function-onload/282571 "2009-02-23T20:23:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![michdd](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@michdd](https://forum.kirupa.com/u/michdd)
#### Post date: [February 23, 2009, 8:23pm UTC](https://forum.kirupa.com/t/running-a-function-onload/282571/1 "2009-02-23T20:23:37Z")

</div>

Is there a way that I can run a function when it first loads, as if it wasn’t inside of the function, but still be able to call that block of code as a function later on?

For example if I did…

```auto

someFunction();

function someFunction():void{
//do this
}

```

It wouldn’t work correctly… I need it to do what is inside the function as if it wasn’t in the function, which it loads, but also be able to call it again later on.
