php 中弹出窗口的实现方法包括:使用 javascript alert 函数;使用 html dom window.alert 方法;使用 php header 函数;自定义弹出窗口。
PHP 弹出窗口的实现
使用 JavaScript Alert 函数
echo "<script>alert('弹出窗口的内容');</script>";
使用 HTML DOM Window.alert 方法
echo "<script>window.alert('弹出窗口的内容');</script>";
使用 PHP header 函数
header("Location: popup.html");
自定义弹出窗口
echo "<script type="text/javascript">
function popup() {
var width = 400;
var height = 400;
var left = (screen.width - width) / 2;
var top = (screen.height - height) / 2;
var windowFeatures = 'width=' + width + ',height=' + height +
',left=' + left + ',top=' + top;
var newWindow = window.open('popup.html', '', windowFeatures);
newWindow.focus();
}
</script>";
echo "<button onclick="popup()">打开自定义弹出窗口</button>";