2012-08-27 18 views
0

可能重复:
Javascript close alert boxalert()后重定向到另一个页面?

您好我想问一下,如果有可能有点击它会弹出一个提示框,当一个id #myID,几秒钟后没有点击OK按钮上的警报,它会重定向到另一个页面?这是我的代码:

$('#myID).click(function(){ 
    alert('Ta-da! Do not click the OK button just wait for a few seconds before it redirects to other page.'); 
}) 

不知何故,这就是我想要的。那可能吗?

+3

只有一个自定义对话框,不与内置'alert'。 –

+0

@FelixKling谢谢,但我怎么会在自定义对话框上做到这一点? –

+1

@CHi:HTML + CSS + JS'

Custom Message
'AND'#my-dialog {/ * CSS Properties to center and zindex * /}'AND JS to add dialog to DOM,add timeout,and put a nice overlay on things 。 –

回答

2

使用自定义对话框:如果您没有在您的网站上使用jQuery ui等任何插件,可以使用一个快速对话框。

var dialog = $('<div id="dialog"> You are going away, Bye Bye </div>'); 
dialog.css({ 
    position:'fixed', 
    top: 100, 
    left: '50%', 
    width: '200px', 
    'margin-left': '-100px', 
    'z-index' : 99999, 
    border: '1px solid #444444', 
    'background-color' : '#FFFFF' 
    }); 
$('body').append(dialog); 

http://jsfiddle.net/R7qSR/

+2

我在最后加上了OP想要的超时时间。 http://jsfiddle.net/R7qSR/1/'var t = setTimeout(function(){$(“#dialog”)。remove();},3000)'' –

相关问题