html调用js变量和函数的几个方法
2014-01-10 11:16
615 查看
<span style="font-size:18px;"><html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> var RestID = 2;//javascript变量 function a() {//javascript函数 window.open("showNews.aspx?id= " + RestID); } </script> </head> <body> <form id="form1" runat="server"> <script language="javascript" type="text/javascript"> var str1,str2 str1="fdsgdg dsfdsf china" str2="武汉市广播电视大学" document.write("显示字符串1:"+str1+"<br>") document.write("显示字符串2:" + str2 + "<br>") //document.write()函数的写法很重要,写好才能正确的读到javascript的参数 <span style="color:#ff6666;">//方式一,打开新窗口,转到新链接 </span> document.write(" <a href= 'showNews.aspx?id="+RestID+"' style='text-decoration:none; color:Black;' target='_blank'> 目标页 </a> ") </script> <span style="color:#ff9966;">//方式二,使用javascript:location.href,但是不能在新窗口中打开链接 </span> <a href= "javascript:location.href= 'showNews.aspx?id= ' + RestID " style=" text-decoration:none; color:Black;" target="_blank"> 目标页 </a> <span style="color:#33cc00;">//方式三,使用javascript:open,只能在搜狗浏览器里打开,在IE、火狐、360浏览器里面都打不开,就是说明这个方法不太好 </span> <a href= "javascript:open( 'showNews.aspx?id= ' + RestID)" style=" text-decoration:none; color:Black;" target="_blank"> 目标页 </a> <span style="color:#ff6666;">//方式四使用window.open但是鼠标为箭头而不是表示链接时的手型, </span> <a onclick= "window.open( 'showNews.aspx?id= ' + RestID)" style=" text-decoration:none; color:Black;" target="_blank"> 目标页 </a> <span style="color:#009900;">//方式五调用 javascript函数 ,但是鼠标为箭头而不是表示链接时的手型, </span> <a onclick= "javascript:a()" style=" text-decoration:none; color:Black;" target="_blank"> 目标页 </a></form> </body> </span>
相关文章推荐
- html调用js变量和函数的几个方法
- HTML父页面调用iframe子页面中js变量和方法
- 在Angular外部使用js调用Angular控制器中提供的函数方法或变量
- FLASH CC 2015 CANVAS (二)html中写JS调用flash中的元件、函数、变量
- 在html中引入外部js文件,并调用带参函数的方法
- 在html的<img src="">中调用js的函数或者js变量来指定图片路径
- Angular外部使用js调用Angular控制器中的函数方法或变量用法示例
- 在Angular外部使用js调用Angular控制器中提供的函数方法或变量
- php部分(查看文件、建立站点、语法变量、变量的几个方法、“全局局部变量的调用”、static、函数参数的作用域);
- HTML父页面调用iframe子页面中js变量和方法
- FLASH CC 2015 CANVAS (三) flash中写JS调用html中JS的函数,变量
- JS中跨页面调用变量和函数的方法(例如a.js 和 b.js中互相调用)
- html_a标签中调用js函数的方法
- 在Angular外部使用js调用Angular控制器中提供的函数方法或变量
- JavaScript基础(基本语法:变量、语句、数组、函数、对象、全局方法以及js与java不同,js与html关联)
- [Asp.net+JS]asp.net中调用javascript自定义函数的方法总结
- js调用后台方法、变量(C#)
- jsp 在超链接上调用onclick,js方法函数,a标签
- Android 使用html做UI的方法---js与java的相互调用
- jQuery中将函数赋值给变量的调用方法