如何在 javascript 中创建一个显示信息的弹出窗口/警报,同时允许用户在 HTML 表单的输入字段中输入数据。
问问题
750 次
1 回答
2
HTML:
<p>testingtestingtestingtestingtestingtestingtestingtestingtest ingtestingtestingtestingtestingtestingtestingtestingtestingt
estingtestingtestingtestingtestingtestingt estingtestingtestingtestingtestingtesting</p>
<input
type="button" value="click for popup" onClick="popup()" />
CSS:
#pop
{
width: 200px;
height: 200px;
border: solid 1px #000;
margin-top: -30px;
margin-left: 20px;
position: fixed;
background-color: #fff;
}
Javascript:
window.onload = function () {
var popup = document.createElement("div");
var text = document.createTextNode("blah blah blah");
popup.appendChild(text);
popup.style.visibility = "hidden";
popup.id = "pop";
document.getElementsByTagName("body")[0].appendChild(popup);
};
window.popup = function () {
var pop = document.getElementById("pop");
pop.style.visibility = "visible";
window.setTimeout(function(){document.getElementById("pop").style.visibility="hidden";},1000);
};
于 2013-01-15T04:21:31.297 回答