免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1833 | 回复: 1
打印 上一主题 下一主题

js 常用技巧(添加中...) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-01-12 16:07 |只看该作者 |倒序浏览
js 常用技巧(添加中...)





1,页面一开始加载js函数
方法1,body的onload属性中指定
方法2,在<script></script>中写函数名,如
  1. <script>
  2.   test();

  3.   function test(){
  4.    ...
  5.   }
  6. </script>
复制代码
2,a href的一个js
  1. <a style="color: blue;cursor: hand" href="<c:url value='/pps/toForward_viewPPS.action?vodId=${pps.id}'/>" onclick="javascript:if(confirm('此节目已经入过库,确认恢复?')) return true;else return false;"><font color="red"> 恢复</font></a>
复制代码
这个onclick的动作返回true的时候执行href中的请求。

3,js 请求提交
  1. 1, document.form的名字.submit;
  2. 2, document.getForms[0].submit;
  3. 3, document.getElementById(formId).submit;
  4. 4, var url = "<c:url value='' />";
  5.     window.location.href = url;
复制代码
5, 使用ajax提交
使用get方式
  1. var url = "<c:url value='/userGroup/ajaxDelUserGroup.action?userGroupId='/>"+id;
  2. var myAjax = new Ajax.Request( url,{method: "POST", asynchronous: true , onComplete: ajaxCallBack } );
复制代码
使用post方式
  1. var myAjax = new Ajax.Request( url,{method: "POST",parameters:Form.serialize(form的ID),asynchronous: true ,onComplete: ajaxCallBack } );
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-01-12 16:08 |只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP