Popup điều chỉnh size

Trở về

  • 4,884

Với dạng plugin này chúng ta có thể điều chỉnh kích thước cho từng popup khác nhau trong cùng trang hoặc khác trang.

Popup với width và height

Cách sử dụng ngoài việc lấy tự động đường dẫn tới popup, còn có thể điều chỉnh width và height dễ dàng.

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Học Web Chuẩn</title>
<script>
function popup(url,w,h) {
    var name        = 'popup';
    var popupWindow = window.open(url,
                                  name,
                                  'width='+ w + ',
                                  height=' + h + ',
                                  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="popup.html" onClick="return popup(this.href,'400','300')">Click mở Popup</a></p>
</body>
</html>

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

Click mở Popup size

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.

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.