1

I have 2 functions on a seperate page that I am including of the header of the .html page. Under the part where I include it, I have this code: window.onload = func1;

I want to take that little snippet of code, and include it inside the included .js page which has the function in it, so essentially there will be the function, then right under that the window.onload thing. But when I do this, the code doesnt work, any ideas?

The code isnt the problem, if I do:

function alert1() {
alert("hi");    
}
window.onload = alert1;

Then it still doesnt show up because that is in the included .js page

<script type="text/javascript" src="menu.js"></script>
2
  • Could you show some code to enlighten us? ;) Commented Feb 27, 2010 at 16:56
  • There's no reason that shouldn't work. Please post the actual code. It would also help if you could be a little more specific about what "doesn't work" means - are there errors? any effects at all? Commented Feb 27, 2010 at 16:57

1 Answer 1

2

Is this what you have? This actually works:

function func1(){
    alert('Works');
}

window.onload = func1;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.