一个javascript问题求助,其实我想实现的功能是用层来代替浏览器弹出的窗口,例如alert()等,但当我弹出层的时候,层函数下面的代码继续执行,有什么办法可以象alert()一样,当执行alert()后,如果不点确定alert()后面的代码就不执行呢?大家帮下忙。例如:
alert();
xxx;
xxx;
alert()下的xxxx是不会执行。而我自定义的层:
showBox();//假设这个函数可以显示和alert()一样内容的层,带有一个确定按键。
xxxxx;
xxxxxx;
showBox()下面的xxxx代码执行了,我想等待点层的确定后再运行xxxx;
alert();
xxx;
xxx;
alert()下的xxxx是不会执行。而我自定义的层:
showBox();//假设这个函数可以显示和alert()一样内容的层,带有一个确定按键。
xxxxx;
xxxxxx;
showBox()下面的xxxx代码执行了,我想等待点层的确定后再运行xxxx;
解决方案 »
- Jsp中如何实现选择左边待选框中的一条或多条记录到右边已选框中
- Hibernate分页问题!!
- 关于优先级选举主服务器的问题
- 在线跪求java编写客户端直接调用外部Web Service的写法
- 我应选择何种方法实现简单交互式网页的制作?
- 100分求jsp的在线音乐源代码
- 如何做一个自动匹配的多列下拉框(有源码)
- jsp里如何判断一个int类型的变量是不是为空?在线等,解决就结帖
- 关于使用PreparedStatement对象setDate方法的问题,如何将表单中提取的时间格式的字符串转换成java.sql.Date类型。
- 请高手进来讨论一下JSP分页的最佳方法!
- hibernate 循环删除的问题
- 列出时间的代码
{
if(window.confirm("确认退出?"))
{
XXXXXXXXXXXX;
XXXXXXXXX
}
}
首先多谢你的回答,但你没了解我要的功能。我要的是用层来模仿alert(),confirm()等功能。
var W=screen.width;
var H=screen.height;
//Get document
function get(id){
return document.getElementById(id);
}
//Create document
function create(t){
return document.createElement(t);
}
//Validate is IE
function isIE(){
return (document.all&&window.ActiveXObject&&!window.opera)?true:false;
}
//Get Page width
function getBodySize(){
var bodySize=[];
with(document.documentElement){
bodySize[0]=(scrollWidth>clientWidth)?scrollWidth:clientWidth;
bodySize[1]=(scrollHeight>clientHeight)?scrollHeight:clientHeight;
}
return bodySize;
}
//Cover window
function popCover(){
if(get("cover_div")){
get("cover_div").style.display='block';
}else{
var coverDiv=create('div');
document.body.appendChild(coverDiv);
coverDiv.id='cover_div';
with(coverDiv.style){
position='absolute';
background = '#CCCCCC';
left='0px';
top='0px';
var bodySize=getBodySize();
width=bodySize[0]+'px';
height=bodySize[1]+'px';
zIndex=0;
if(isIE()){
filter="Alpha(Opacity=60)";
}else{
opacity=0.6;
}
}
}
}//Show country
//Get country information
function getCountry(){
var url="getcountry.action";
var parame;
jQuery.post(url,parame,function(data){
changeDiv_country();//Change country div;
showDiv_country(data);//show country div;
popCover();//block body div;
}, 'json');
}
//Set country div information
function showDiv_country(data){
var countrydiv=get("countrydiv");
//Get result country
var str="";
str+="<a href='javascript:closeCountry()'>close<a><br>";
if(data.countrylist==null){
str+="Cannot get countrylist";
}
var i=1;
for(var key in data.countrylist){
var id=key.toString();
var name=data.countrylist[id];
str+="<td>";
str+="<a href=\"javascript:setCountry("+id+",'"+name+"')\">"+name+"</a>";
if(i%3==0){
str+="<br>";
}
i++;
}
str+="</td>";
str+="<br>";
countrydiv.innerHTML=str;
countrydiv.style.display="block";
}
//Set div style
function changeDiv_country(){
var countrydiv=get("countrydiv");
countrydiv.style.position="absolute";
countrydiv.style.border = "1px solid #CCCCCC";
countrydiv.style.background ="#F6F6F6";
var i=10;
var bodySize=getBodySize();
countrydiv.style.left=(bodySize[0]-i*i*4)/2+"px";
countrydiv.style.top=(bodySize[1]/2-100-i*i)+"px";
countrydiv.style.width=i*i*4 + "px";
countrydiv.style.height=i*i*1.5+ "px";
}//Set value for hidden input
function setCountry(id,name){
get('10').value=name;
get('country_value').value=id;
get('11').value="";//Set state null
get('state_value').value="";
closeCountry();
}//Clost country pop window
function closeCountry(){
get('countrydiv').style.display='none';
get('cover_div').style.display='none';
}
这是我很早以前做的一个,现在不用了,楼主可以试试,应该可以用的