简体   繁体   English

特定网页的javascript

[英]javascript for specific web page

currently I have different javascript onload commands for each of my web pages. 目前,每个网页都有不同的javascript onload命令。 Is it possible to compile all of them in one javascript file and assign the functions to a specific web page? 是否可以将所有这些文件编译到一个javascript文件中并将这些功能分配给特定的网页? I'm currently working with an ASP.net MVC project, so I load a Layout.html when I start my application. 我目前正在使用ASP.net MVC项目,因此在启动应用程序时会加载Layout.html。 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. 我想我想要的是只有一个JavaScript文件并将其加载到我的layout.html中,当我打开另一个页面时,将运行特定的javascript函数。

为每个页面的body onLoad附加函数。

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. 您无需在每个页面上加载脚本文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用javascript在网络上显示特定的Facebook事件页面 - display specific facebook event page on web with javascript Javascript单击网页中的特定按钮 - Javascript Click the specific button in a web page 使用Javascript根据URL参数重定向到特定网页 - Redirection to a specific web page based on URL parameter using Javascript 在网页上出现特定单词时获取 JavaScript 警报 - Get JavaScript alert in case of specific words on web page Javascript-将字符添加到网页特定字段中的现有字符串作为客户端 - Javascript - add a character to existing string in specific field of web page as a client Javascript从网页上传文件到特定的谷歌驱动器帐户 - Javascript upload file from web page to specific google drive account 使用Javascript查找网页上特定坐标的像素颜色 - Using Javascript to Find the Pixel Color at Specific Coordinates on a Web Page 页面特定的Javascript不起作用 - Page Specific Javascript Not Working 页面特定的javascript函数 - Page specific javascript function 当浏览器进入特定网页时,是否可以通过浏览器的JavaScript控制台自动执行预定义的JavaScript? - is there a way to auto execute a predefined JavaScript through the JavaScript console of a browser when it enters a specific web page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM