Home > Web Front-end > H5 Tutorial > body text

HTML5 and CSS3 tutorial summary (recommended)

黄舟
Release: 2017-02-20 13:33:37
Original
1481 people have browsed it

About the separation of onclick behavior and content

1. Trigger pop-up windows through links (this method is not recommended!!!)


<a href=&#39;#&#39;    

        onclcik = "window.open(&#39;holiday_pay.html&#39;,WinName,&#39;width=300, height = 300&#39;);">  

    Holiday Pay    

    </a>
Copy after login



If JS is disabled and the link cannot guide the user to the corresponding page, do not assign "#" and similar values ​​to the href attribute

2. Ordinary situations

<a href=&#39;holiday_pay.html&#39;    

        onclcik = "window.open(this.href,WinName,&#39;width=300, height = 300&#39;);">  

    Holiday Pay    

    </a>
Copy after login



3.0 A large number of repeated links, assign an identifiable class name to each link, and add listeners for each click event using jQuery Device

<a href="holiday_pay" class="popup">Holiday pay</a>  

      

    var links = $("a.popup");   

      

    links.clcik(function(event){   

       event.preventDefault();   

       window.open($(this).attr(&#39;href&#39;));      

    });
Copy after login



3.1 Set the pop-up window size through multiple custom data types

<a href ="holiday_pay.html"  

        data-width="600"  

        data-heigth = "400"  

        title = "Holiday Pay"  

        class = "popup"> Holiday pay </a>
Copy after login



$(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+"");   

    }) ;   

    });
Copy after login



The above summary (recommendation) of HTML5 and CSS3 example tutorials is all the content shared by the editor. I hope it can be useful to everyone. A reference. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!