首页 > Web开发 > 详细

HTML5和CSS3实例教程[总结一]

时间:2016-07-17 13:23:22      阅读:254      评论:0      收藏:0      [点我收藏+]

关于onclick的行为与内容分离 

  1. 通过链接触发弹出窗口方式 (不推荐使用此方法!!!)
<a href=‘#‘ 
    onclcik = "window.open(‘holiday_pay.html‘,WinName,‘width=300, height = 300‘);">
Holiday Pay 
</a>

如果JS被禁用链接无法引导用户进入对应页面,不要为href属性赋"#"及类似的值

  2.普通情况

<a href=‘holiday_pay.html‘ 
    onclcik = "window.open(this.href,WinName,‘width=300, height = 300‘);">
Holiday Pay 
</a>

  3.0  大量重复链接,为每个链接分配可识别类名,通过使用jQuery为每个click事件分别添加监听器

<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  通多自定义数据类型设置弹出窗口尺寸大小 

<a href ="holiday_pay.html"
    data-width="600"
    data-heigth = "400"
    title = "Holiday Pay"
    class = "popup"> Holiday pay </a> 
$(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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!