This section can be used to submit suggestions for Extension Builder.
Note that this section is not monitored for support.
Forum rules
This forum section can be used to submit suggestions for Extension Builder.
Note that this section is not monitored for support.
-
GrahamW
-

- Posts: 243
- Joined: Sat Jul 08, 2017 5:02 am
Post
by GrahamW »
I have a javascript I wrote that pre loads images and I need to add this into my extension
How can I get it to add the onload="preLoad()" part in the script directly after the opening body tag
Graham
-
Pablo
-
- Posts: 24229
- Joined: Sun Mar 28, 2004 12:00 pm
- Location: Europe
-
Contact:
Post
by Pablo »
You cannot insert code directly inside the body tag with an extension.
However you can write your code like this:
Code: Select all
<script type="text/javascript">
window.onload = function()
{
preLoad();
};
</script>
or jQuery:
Code: Select all
<script type="text/javascript">
$(document).ready(function() // or $(function()
{
preLoad();
});
</script>
-
BaconFries
-

- Posts: 6246
- Joined: Thu Aug 16, 2007 7:32 pm
Post
by BaconFries »
Just as Pablos second suggestion but using 'body'
Code: Select all
<script type="text/javascript">
$(document).ready(function () {
document.body.onload = function ()
}
preLoad();
};
</script>