Romeo
Romeo

Reputation: 1831

javascript for specific web page

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.

Upvotes: 0

Views: 58

Answers (2)

Ashish
Ashish

Reputation: 21

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.

Upvotes: 0

patrykf
patrykf

Reputation: 449

Attach functions to body onLoad for every page.

Upvotes: 1

Related Questions