0

currently I have different javascript onload commands for each of my web pages. Is it possible to compile all of them in one javascript file and assign the functions to a specific web page? I'm currently working with an ASP.net MVC project, so I load a Layout.html when I start my application. I guess what I want is to only have a single javascript file and load it in my layout.html, and when I open another page a specific javascript function will run.

2
  • How about making separate function for every webpage and attach it to <body onLoad="function"> ? This way whole javascript can stay in one file. Commented Aug 26, 2014 at 10:26
  • Without seeing a specific example of your code i.e. the way you are onloading at the moment, it is tricky to advise precisely -- stackoverflow.com/help/how-to-ask Commented Aug 26, 2014 at 10:35

2 Answers 2

1

Attach functions to body onLoad for every page.

Sign up to request clarification or add additional context in comments.

Comments

0

Load your script from Layout page and just set this layout page as layout in all other views. You can load function from that script from any view page. you don't need to load script file on every page.

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.