admin管理员组文章数量:1431420
I have a JavaScript alert popup on my page. Problem I am having with it is that instead of waiting for the user to actually click the OK button, it simply does a redirect, something it ought to do AFTER the OK button has been clicked. Can anyone please help me tweak my code so as to get this working as it ought to please?
function f()
{
ar ape =radalert('<div align=""center"" style=""font-weight: bold;""> OPEN BOX HERE</div>', 123, 200);
if(ape)window.location.href = "/Default.aspx";
Sys.Application.remove_load(f);
}
Sys.Application.add_load(f);
I have a JavaScript alert popup on my page. Problem I am having with it is that instead of waiting for the user to actually click the OK button, it simply does a redirect, something it ought to do AFTER the OK button has been clicked. Can anyone please help me tweak my code so as to get this working as it ought to please?
function f()
{
ar ape =radalert('<div align=""center"" style=""font-weight: bold;""> OPEN BOX HERE</div>', 123, 200);
if(ape)window.location.href = "/Default.aspx";
Sys.Application.remove_load(f);
}
Sys.Application.add_load(f);
Share
Improve this question
edited Feb 2, 2022 at 15:10
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Dec 18, 2009 at 15:16
KobojunkieKobojunkie
6,56532 gold badges112 silver badges164 bronze badges
3 Answers
Reset to default 4You can use the add_close
method to attach a callback function to know when the alert is closed:
var win = radalert('foo');
win.add_close(function () {
alert('bar'); // This will be executed when the radalert is closed.
});
More info:
- Telerik RadWindow Client-Side API
You're not using a JavaScript alert
(in the sense of the built-in function), it looks like you're using something called radalert
(from Telerik). That means it can't behave like a JavaScript alert
, which brings script processing to a screeching halt while it's on-screen.
I know nothing about Telerik, but most of these alert replacements offer a callback you can pass that gets triggered when the alert is cleared. That's where you want your window.location.href = ...
code.
Usually this looks something like this:
function blah() {
niftyAlertThingy("Here's my message", {
onOK: function() {
window.location.href = "/Default.aspx";
// etc.
}
});
}
That blah
function returns immediately, with the alert still on the page; then the alert code calls your callback when the user clicks OK.
I'm sure the Telerik radalert
has something similar...
I would think your code would need more explanation and possibly your code behind too (just the relevant code on how you handle "OK" Click). My experience with telerik is not good. I would suggest you to try jQuery UI. It gives you better control on how you can handle events and where.
Example( From here)
$(function(){
$("#dialog").dialog({
autoOpen: false,
modal:true,
buttons : {
"Yes" : function() {
$(this).dialog("close");
eval($("#<%= hdnBtnPostback.ClientID %>").val());
},
"No" : function() {
$(this).dialog("close");
},
"Maybe": function() {
$(this).dialog("close");
//what should we do when "Maybe" is clicked?
}
}
});
});
本文标签: dom eventsJavaScript alert with confirmationStack Overflow
版权声明:本文标题:dom events - JavaScript alert with confirmation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745555499a2663161.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论