Popup

Trở về

  • 3,035

Popup là mở một cửa sổ (window) mới khi click vào một liên kết, việc này cho phép mở một nội dung mới mà không đóng nội dung đang xem.

Popup

Khi ta click vào một liên kết thì xuất hiện một của số mới, việc mở ra cửa sổ mới như vậy gọi là popup.

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Học Web Chuẩn</title>
<script>
function popup(url) {
    var width       = 540;
    var height      = 400;
    var name        = 'popup';
    var popupWindow = window.open(url,
                                  name,
                                  'width=' + width + ',
                                  height=' + height + ',
                                  status=no,
                                  location=no,
                                  toolbar=no,
                                  scrollbars=yes,
                                  menubar=no,
                                  resizable=no'
                                  );
    popupWindow.focus();
    return false;
}
</script>
<style>
* { /* reset lại margin và padding cho các tag */
    margin: 0;
    padding: 0;
}
</style>
</head>
<body>
<p><a href="/example/popup.html" onClick="return popup(this.href)">Click mở Popup</a></p>
</body>
</html>

Hiển thị trình duyệt:

Click mở Popup

Download file để thực hành

Thuộc tính điều khiển popup

Thuộc tính Giá trị Mô tả
width đơn vị Chiều rộng cửa sổ popup.
height đơn vị Chiều cao cửa sổ popup.
status yes / no Ẩn hiện trạng thái.
location yes / no Ẩn hiện phần location.
toolbar yes / no Ẩn hiện toolbar.
scrollbars yes / no Ẩn hiện thanh scrollbars.
menubar yes / no Ẩn hiện thanh menu
resizable yes / no Popup có resize hay không.
left đơn vị Canh trái cho popup.
top đơn vị Canh bên trên cho popup.

Có một bình luận cho “Popup”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.