Я сделал простой скрипт для изменения подтверждения по умолчанию в JavaScript.надеюсь, что это работа для вас:)
var CONFIRM_BUTTON_YES = "Ya";
var CONFIRM_BUTTON_NO = "Tidak";
if(document.getElementById) {
window.confirm = function(title,txt,callback,parameter) {
//title = your confirm title, txt = your message here, callback = call your function after u get result, parameter = ( optional ) for your function
createCustomConfirm(title,txt,callback,parameter);
}
}
function createCustomConfirm(title, txt,callback,parameter) {
d = document;
if(d.getElementById("modalContainer")) return;
// create the modalContainer div as a child of the BODY element
mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
mObj.id = "modalContainer";
// make sure its as tall as it needs to be to overlay all the content on the page
mObj.style.height = document.documentElement.scrollHeight + "px";
// create the DIV that will be the alert
alertObj = mObj.appendChild(d.createElement("div"));
alertObj.id = "alertBox";
// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
// center the alert box
alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
$('#alertBox').css("display","none");
// create an H1 element as the title bar
h1 = alertObj.appendChild(d.createElement("h1"));
h1.id = "popup_title";
h1.appendChild(d.createTextNode(title));
// create a paragraph element to contain the txt argument
msg = alertObj.appendChild(d.createElement("p"));
msg.innerHTML = txt;
// create an anchor element to use as the confirmation button.
btn1 = alertObj.appendChild(d.createElement("a"));
btn1.id = "closeBtn";
btn1.appendChild(d.createTextNode(CONFIRM_BUTTON_YES));
btn1.href = "#";
btn2 = alertObj.appendChild(d.createElement("a"));
btn2.id = "cancelBtn";
btn2.appendChild(d.createTextNode(CONFIRM_BUTTON_NO));
btn2.href = "#";
$("#closeBtn").focus().select();
$("#closeBtn, #cancelBtn").keypress( function(e) {
if( e.keyCode == 13 ) $("#closeBtn").trigger('click');
if( e.keyCode == 27 ) $("#cancelBtn").trigger('click');
});
try {
$("#alertBox").draggable({ handle: $("#popup_title") });
$("#popup_title").css({ cursor: 'move' });
} catch(e) { /* requires jQuery UI draggables */ }
// set up the onclick event to remove the alert when the anchor is clicked
btn1.onclick = function() { removeCustom(); if( callback ) callback(true,parameter); }
btn2.onclick = function() { removeCustom(); if( callback ) callback(false,parameter); }
$('#alertBox').fadeIn();
}
// removes the custom from the DOM
function removeCustom() {
document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
А вот простой скрипт для вызова, который подтверждает ...
onclick="confirm('Just asking','go to facebook ?',gotofacebook,'login');"
Функция для обратного вызова:
function gotofacebook(value,parameter) {
if (value) {
switch(parameter)
{
case 'login':
window.location ="https://www.facebook.com/login.php";
break;
default:
window.location ="https://facebook.com";
}
}
}
Вы также можете изменить это для предупреждения или подсказки по умолчанию.последнее ... вам нужно собрать CSS для этого подтвердите:)