Reputation: 81
How do I take the cancel Button from the window.confirm?? Is there a way to taking it out and only the OK button will show up?
Upvotes: 5
Views: 14001
Reputation: 32949
You can simply use the alert
. Following is an example:
<button id="test"> Go To Another Page</button>
<br><br>
<iframe src='http://www.example.com' height="400px" width="100%" id="page"></iframe>
$(document).ready(function(){
$('#test').click(function(){
var page = $('iframe');
alert("You'll be redirected to a new page now");
page.attr('src', 'http://www.monkeyman.com'); // This line is executed once you hit ok on the alert.
});
});
Here is a working JSFiddle. I had to use an iframe because of jsfiddle. In your scenario you may want to remove the iframe thing and simply change:
page.attr('src', 'http://www.monkeyman.com');
to
window.location('http://www.monkeyman.com');
Upvotes: 0
Reputation: 173532
If you don't want a cancel button, you might as well just use alert()
:
alert('This operation is not possible');
In beautiful ascii art it looks like this:
+-----------------------------------+
| |
| This operation is not possible |
| |
| +--------+ |
| | OK | |
| +--------+ |
+-----------------------------------+
When either OK is clicked or the dialog is dismissed, the next statement in your code will be executed.
If the next statement should be conditional, you'd have to stick with confirm()
unfortunately.
Upvotes: 8
Reputation: 150253
window.alert
is what you want.
Or simply alert
, just like window.confirm
can be confirm
(unless you hide those with variables with those names.
Upvotes: 1