1. 运用 `window.open` 办法
```html Popup Window Example
Open Popup
function openPopup { var popup = window.open;}
在这个比如中,当用户点击按钮时,会打开一个新的浏览器窗口,显现指定的 URL。
2. 运用 CSS 和 JavaScript 创立自定义弹出窗口
```html Custom Popup Window Example .popup { display: none; position: fixed; zindex: 1; left: 50%; top: 50%; width: 300px; padding: 20px; backgroundcolor: f9f9f9; border: 1px solid 888; boxshadow: 0 4px 8px 0 rgba; webkittransform: translate; transform: translate; }
.popupcontent { backgroundcolor: fefefe; margin: 15% auto; padding: 20px; border: 1px solid 888; width: 80%; }
.close { color: aaa; float: right; fontsize: 28px; fontweight: bold; }
.close:hover, .close:focus { color: black; textdecoration: none; cursor: pointer; }
Open Popup
未经允许不得转载:全栈博客园 » html弹出窗口,```html Popup Window Example