您在混合隐喻。 CSS只是一种演示技术,用于确定某种东西的风格。没有像“css弹出框”这样的东西。
你想要做的是有一个HTML元素(可能是一个div),它包含你想要显示的信息,最初设置为不可见(你用display:none; style使用CSS)。您所描述的实质上是一种AJAX交互,它使用Javascript来分析表单的内容,将数据发送到服务器进行评估,并返回要显示的消息(不会触发回发/进入新页面)。该Javascript也会处理将HTML元素的显示设置为true的CSS部分。
这是一个相当常见的情况,所以你应该能够在网上找到片段。
...但这里有一个超级愚蠢的例子
<html>
<head>
<title>AJAX Test</title>
</head>
<body>
<form action="#">
<input type="text" id="enterStuff" />
</form>
<div id="response" style="display:none;">
<p id="message">Put stuff in me</p>
</div>
<script type="text/javascript">
jQuery(document).ready(function(){
registerEventListeners();
});
function registerEventListeners(){
jQuery("#enterStuff").change(getData);
}
function getData(){
jQuery.ajax({
type : 'POST',
data : {
stuff : jQuery("#enterStuff").val(),
},
url : "http://localhost/myprocessor.php",
success : showCool,
complete : updateDisplay
});
}
function showCool(data, textStatus, jqXHR){
var selector = jQuery("#message");
selector.val(data)
}
function updateDisplay() {
jQuery("#response").show();
}
</script>
</body>
</html>
那么你myProcessor.php必须读取变量的值,做一些逻辑,和回声响应。
难道你不能在这个弹出窗口中使用对该脚本的ajax请求吗? –