关于onclick的行为与内容分离
1.通过链接触发弹出窗口方式 (不推荐使用此方法!!!)
xml/html code复制内容到剪贴板
- <a href='#'
- onclcik = "window.open('holiday_pay.html',winname,'width=300, height = 300');">
- holiday pay
- </a>
如果js被禁用链接无法引导用户进入对应页面,不要为href属性赋"#"及类似的值
2.普通情况
xml/html code复制内容到剪贴板
- <a href='holiday_pay.html'
- onclcik = "window.open(this.href,winname,'width=300, height = 300');">
- holiday pay
- </a>
3.0 大量重复链接,为每个链接分配可识别类名,通过使用jquery为每个click事件分别添加监听器
xml/html code复制内容到剪贴板
- <a href="holiday_pay" class="popup">holiday pay</a>
-
- var links = $("a.popup");
-
- links.clcik(function(event){
- event.preventdefault();
- window.open($(this).attr('href'));
- });
3.1 通多自定义数据类型设置弹出窗口尺寸大小
xml/html code复制内容到剪贴板
- <a href ="holiday_pay.html"
- data-width="600"
- data-heigth = "400"
- title = "holiday pay"
- class = "popup"> holiday pay </a>
javascript code复制内容到剪贴板
- $(function(){
- $(".popup").click(function(event){
- event.preventdefault();
- var href=$(this).attr("href");
- var width = $(this).attr("data-width");
- var height = $(this).attr("data-height");
- var popup = window.open(href,"popup","height="+height+",width="+width+"");
- }) ;
- });
以上这篇html5和css3实例教程总结(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
原文地址:http://www.cnblogs.com/liul0703/p/5677644.html
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
前端的cookie
前端的cookie先自己总结一下(课本的相关具体细节看后面)先提一下:一定不要在 cookie 中存储重要和敏感...
[阅读全文]
-
-
-
-
-
-
-
-
网友评论