HTML5和CSS3執行個體教程[總結一],html5css3
關於onclick的行為與內容分離
<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+"");}) ;});