Reputation: 770
Here is my javascript code
<script type="text/javascript">
Alert.render('Saved!','myurl.php');
</script>
and the render function is
function CustomAlert() {
this.render = function (dialog,url) {
var winW = window.innerWidth;
var winH = window.innerHeight;
var dialogoverlay = document.getElementById('dialogoverlay');
var dialogbox = document.getElementById('dialogbox');
dialogoverlay.style.display = "block";
dialogoverlay.style.height = winH + "px";
dialogbox.style.left = (winW / 2) - (550 * 0.5) + "px";
dialogbox.style.top = "100px";
dialogbox.style.display = "block";
document.getElementById('dialogboxhead').innerHTML = "Heading";
document.getElementById('dialogboxbody').innerHTML = dialog;
document.getElementById('dialogboxfoot').innerHTML = "<button class='btn btn-info' onclick='Alert.ok(\"" + url + "\")'>OK</button>";
}
this.ok = function (url) {
window.location.href(url);
document.getElementById('dialogbox').style.display = "none";
document.getElementById('dialogoverlay').style.display = "none";
}
}
var Alert = new CustomAlert();
my problem is the page is not redirecting after clicking the 'Ok' button. Please help me??
Upvotes: 0
Views: 943
Reputation: 4422
change
onclick='Alert.ok(\"" + url + "\")'>
to
onclick='this.ok(\"" + url + "\")'>
because Alert in undefined within the scope of CustomAlert
Upvotes: 0
Reputation: 6722
window.location.href
is not a function
change window.location.href(url);
to window.location.href = url;
Upvotes: 2