Sunday, October 14, 2012

Tạo cửa sổ popup khi click vào link(cửa sổ thu nhỏ)

Đôi khi bạn phải sử dụng Popup window để tạo liên kết đến một trang web khác. Popup window thường xuyên được sử dụng trong thiết kế web. Bạn hãy click chuột vào liên kết Demo dưới đây để thấy tác dụng của thủ thuật này.

Để tạo Popup window như thế, trước tiên đặt đoạn code dưới đây vào trước thẻ </head>

<script type="text/javascript">
//<![CDATA[
function OpenPopup(Url,WindowName,width,height,extras,scrollbars) {
var wide = width;
var high = height;
var additional= extras;
var top = (screen.height-high)/2;
var leftside = (screen.width-wide)/2; newWindow=window.open(''+ Url + '',''+ WindowName + '','width=' + wide + ',height=' + high + ',top=' + top + ',left=' + leftside + ',features=' + additional + '' + ',scrollbars=1');
newWindow.focus();
}
//]]>
</script>

Tiếp theo thiết lập cấu trúc HTML như sau và đặt tại vị trí muốn hiển thị liên kết đến một trang web khác.
<a href="javascript: void(0);" onclick=" javascript:OpenPopup('http://chipkool.blogspot.com/','WindowName','510','280','scrollbars=1');">Liên kết đến trang khác</a>


Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 nhận xét

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

 
© Sổ ghi chú
Designed by BlogThietKe Cooperated with Duy Pham
Released under Creative Commons 3.0 CC BY-NC 3.0
Posts RSSComments RSS
Back to top