您的位置:首页 > 其它

关于自动关闭的alert() 的问题

2009-04-10 17:36 459 查看
我制作论坛时想实现:用户发帖后弹出alert对话框“发帖成功”,点确定就转向论坛主页;如果用户不点确定,那么10秒钟后也自动转向论坛主页,请问怎么实现啊?

我曾看到JK_10000(JK) 的文章——自动关闭的alert() ,可是如下???处该怎么写?如何实现点alert对话框中的确定后实现转向啊?

谢谢!

<SCRIPT language=javascript>

showModelessDialog("javascript:alert("发帖成功");???","status:no;resizable:no;help:no;dialogWidth:30px;dialogHeight:40px;");

setTimeout("window.location.href='论坛主页.asp'",3000);

</SCRIPT>

回复人:天堂龙(kc_ren)2006-1-26 13:56:16

showModelessDialog 和 alert 不一样的

一个是新建的窗口 一个是系统提示

showModelessDialog(sURL [, vArguments] [, sFeatures])

vArguments Optional. Variant that specifies the arguments to use when
displaying the document. Use this parameter to pass a value of any
type, including an array of values. The dialog box can extract the
values passed by the caller from the dialogArguments property of the
window object.

???为 window

回复人:黑翼(patchclass)2006-1-26 14:02:38

<SCRIPT language=javascript>

showModelessDialog("javascript:alert("发帖成功");top.location.href='论坛主
页.asp'","status:no;resizable:no;help:no;dialogWidth:30px;dialogHeight:40px;");

setTimeout("window.location.href='论坛主页.asp'",3000);

</SCRIPT>

就可以了吧,3秒内自动转向,如果点确定,马上转向

回复人:一无所(best_inh)2006-1-26 15:50:45

回:patchclass(黑翼)

不行啊!

点确定后,窗口显示的是“论坛主页.asp”的文字,是"index.asp"这几个字,比如把'论坛主页.asp'改成:http://www.163.com 试一下,窗口中就只显示“http://www.163.com ”却不转向网易。

回复人:梅雪香@深圳(zhaoxiaoyang)2006-1-26 18:21:00

alert弹出后,程序是停止运行的,并且无法用代码来关闭,所以只好用其它东西来模拟.

下面是我写过的一个,不是很好的,但能用.

a.htm

<script language="JavaScript">

<!--

/*@cc_on @*/

/*@if (@_win32 && @_jscript_version>=5)

function window.alert(strText){
var
pWin=window.showModalDialog("b.htm",strText,"dialogHeight:116px;
dialogWidth:232px; help: No; resizable: no; status: No; scroll:no;
dialogTop:"+(screen.height-116)/2+"px;
dialogLeft:"+(screen.width-232)/2+"px;");

}

@end @*/

var i=0;

alert("用户名非法!"+i++);

alert("用户名非法!"+i++);

alert("用户名非法!"+i++);

alert("用户名非法!"+i++);

alert("用户名非法!"+i++);

//-->

</script>

b.htm

<html>

<head>

<style type="text/css">

body{ }

td,input{ font-size:12px}

</style>

<script language="JavaScript">

<!--

var str = window.dialogArguments;

function doOk(){

window.returnValue="";

window.close();

}

function setTimer(){

window.setTimeout("document.getElementById('btnOk').click()",1500);

}

document.onclick=function (){

document.getElementById("btnOk").focus();

}

document.oncontextmenu=function (){

document.getElementById("btnOk").focus();

}

//-->

</script>

<title>提示信息 </title>

</head>

<body style="background-color:buttonface; margin:0" onload="setTimer()">

<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">

<tr height="65%">

<td width="25%" align="center" valign="center"><img src="warning.gif" style="width:32px; height:32px"></td>

<td valign="middle">

<script language="JavaScript">

<!--

document.write(str);

//-->

</script>

</td>

</tr>

<tr height="35%">

<td colspan="2" align="center" valign="top">

<input type="button" id="btnOk" value=" 确定 " onclick="doOk()">

</td>

</tr>

</table>

</body>

<html>

warning的图片可以在windows的目录中找到.

本代码关闭的时间是1.5秒,你可以自行设置.

回复人:一无所(best_inh)2006-1-26 19:35:00

是的。但我使终认为简单的代码可以实现

<SCRIPT language=javascript>

showModelessDialog("javascript:alert("发帖成
功");window.close();","status:no;resizable:no;help:no;dialogWidth:30px;dialogHeight:40px;");

setTimeout("window.location.href='论坛主页.asp'",3000);

</SCRIPT>

面代码中
window.close();可以运行——可以实现关闭对话框窗口,我想一定也可以实现转向。就想我们常用到
的<SCRIPT>alert("文字");window.location.href='某某页面.htm';</SCRIPT&
gt;一样

回复人:梅雪香@深圳(zhaoxiaoyang)2006-1-26 20:18:26

<SCRIPT language=javascript>

showModelessDialog("javascript:alert("发帖成
功");window.close();","status:no;resizable:no;help:no;dialogWidth:30px;dialogHeight:40px;");

setTimeout("window.location.href='http://meixx.nonamexz.com'",3000);

</SCRIPT>

这样是可以转向的啊

关于日期的常见操作
http://community.csdn.net//Expert/TopicView2.asp?id=4360247&datebasetype=now
js FAQ贴
http://community.csdn.net//Expert/TopicView2.asp?id=4356360&datebasetype=now
DHTML手册,js手册,dom手册下载,梅花雪的树和日期控件

梅雪香的日期控件.
http://community.csdn.net//Expert/TopicView2.asp?id=4356325&datebasetype=now
回复人:一无所(best_inh)2006-1-26 20:52:18

回上楼

我的意思是点“alert弹出框的确定”马上转向,不点则3秒(或n秒)自动转向。

回复人:海曦(hax)2006-1-26 21:58:24

你要模拟alert框。标准alert会中断js的运行。

回复人:黑翼(patchclass)2006-1-26 22:01:18

<SCRIPT language=javascript>

showModelessDialog("noname3.html",window,"status:no;resizable:no;help:no;dialogWidth:30px;dialogHeight:40px;");

setTimeout("window.location.href='http://www.yuhuatel.com/yang/'",8000);

</SCRIPT>

noname3.html页面中

<script language="JavaScript">

<!--

alert('发帖成功');

window.dialogArguments.location.href='http://www.yuhuatel.com/yang/';

window.close();

//-->

</script>

测试通过

回复人:一无所(best_inh)2006-1-26 22:29:09

ok!!! 感谢: patchclass(黑翼)

就是想要这种的效果!但能不能把它精炼在一段代码中完成呢?

我的这种要求能实现吗?

回复人:一无所(best_inh)2006-1-26 22:34:55

其实我以上这段代码实际是在<iframe height=0 width=0 name=hiddenframe></iframe>中运行的,真正要转向的是父页面(留言页.asp)提交后通过该动作后转向到(论坛首页.asp)

回复人:一无所(best_inh)2006-1-26 22:50:48

<script language="JavaScript">

<!--

alert('发帖成功');

window.dialogArguments.location.href='http://www.yuhuatel.com/yang/';

//-->

</script>

——如何点确定后让dialogArguments的父页面转向啊
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐