WEB调用JavaScript的方式
2011-09-27 11:32
204 查看
概括、在WEB中一共有四种方式可以引用js代码。
1、<script>直接引用代码</script>
2、<script src=xxx.js></script> //间接引用代码
3、<script defer>间接延迟引用代码</script>
4、javascipt:在地址栏中直接执行代码
示例:
out.js
1、<script>直接引用代码</script>
2、<script src=xxx.js></script> //间接引用代码
3、<script defer>间接延迟引用代码</script>
4、javascipt:在地址栏中直接执行代码
示例:
<html> <head> <!--first run--> <script> alert("embedded script is in the head!"); </script> <!--second run--> <script src=out.js></script> <script defer>alert("delay script in the head!");</script> <!--在IE下是加载完body才运行,在firefox下是加载完head就运行--> </head> <body> <!--third run--> <script> alert("embedded script is in the body!"); </script> <!--fourth run--> <script src=out.js></script> <input type="button" value="button1" onclick='alert("button1 is clicked!")'/> <!--所有的事件都以on开头--> </body> </html> <!--还可以在地址栏中输入JavaScript代码,javascript:alert("script in the url!");-->
out.js
alert("out script!");
相关文章推荐
- Webdnpro for java调用BAPI(方式二) 使用JCO
- webservice中的wsdl文件的剖析,已经swebservice客户端调用的几种方式
- 通过web方式远程调用ANT编译(一)
- Android在使用WebView时,通过Javascript调用JAVA函数
- android webview javascriptinterface实现从HTML JS调用ANDROID内部程序
- Javascript中匿名函数的多种调用方式总结
- javascript 具名函数的四种调用方式 推荐第1/3页
- web端通过javascript调用android方法打开新的页面
- javascript的四种函数调用方式
- WebView与 JavaScript 交互方式
- 改变mvc web api 支持android ,ios ,ajax等方式跨域调用
- JavaScript实现二级、多级(N级)联动下拉列表框更新版,支持IE6,FireFox,函数和类两种调用方式,支持到N级,非常通用。
- JavaScript调用com的两种方式
- Android webview中JavaScript与Java方法的相互调用Demo
- webView中JavaScript调用Android方法
- 在Salesforce中使用Javascript调用Apex方法 - Salesforce RemoteAction and webService
- javascript三种函数调用方式
- Android中Webview与javascript的交互(互相调用)
- android中Webview与javascript的交互(互相调用)
- iOS下JS与OC互相调用(六)--WKWebView + WebViewJavascriptBridge