本文介绍了如何使用jQuery更改警报消息的按钮文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在om internet上找到了一个js文件来修改警报消息,但是我不想使用文本"OK",我想将其更改为文本"Back".但它没有运行,我不明白这是什么问题.
希望能得到您的帮助.
文件代码:
Hi All,
I find out om internet a js file to modify alert message, But I don''t want to use text "OK" , i want to change it to text "Back". but it don''t run, I don''t understand what is issue.
I hope that will be received help from you.
code of file:
(function($) {
$.alerts = {
// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
repositionOnResize: true, // re-centers the dialog on window resize
overlayOpacity: .01, // transparency level of overlay
overlayColor: '#FFF', // base color of overlay
draggable: true, // make the dialogs draggable (requires UI Draggables plugin)
okButton: ' 戻る ', // text for the OK button
cancelButton: ' Cancel ', // text for the Cancel button
okButton1: ' Back ', // text for the OK button of modified message dialog
dialogClass: null, // if specified, this class will be applied to all dialogs
// Public methods
alert: function(message, title, modified, callback) {
if( title == null ) title = 'Alert';
$.alerts._show(title, message, null, 'alert', modified, function(result) {
if( callback ) callback(result);
});
},
confirm: function(message, title, callback) {
if( title == null ) title = 'Confirm';
$.alerts._show(title, message, null, 'confirm', modified, function(result) {
if( callback ) callback(result);
});
},
// Private methods
_show: function(title, msg, value, type, modified, callback) {
$.alerts._hide();
$.alerts._overlay('show');
$("BODY").append(
'<div id="popup_container">' +
'<h1 id="popup_title"></h1>' +
'<div id="popup_content">' +
'<div id="popup_message"></div>' +
'</div>' +
'</div>');
if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
// IE6 Fix
var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';
$("#popup_title").text(title);
$("#popup_content").addClass(type);
$("#popup_message").text(msg);
$("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
$("#popup_container").css({
minWidth: $("#popup_container").outerWidth(),
maxWidth: $("#popup_container").outerWidth()
});
$.alerts._reposition();
$.alerts._maintainPosition(true);
switch( type ) {
case 'alert':
if(modified == null || modified== 'false'){
$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
} else {
$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton1 + '" id="popup_ok" /></div>');
}
$("#popup_ok").click( function() {
$.alerts._hide();
callback(true);
});
$("#popup_ok").focus().keypress( function(e) {
if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
});
break;
}
// Make draggable
if( $.alerts.draggable ) {
try {
$("#popup_container").draggable({ handle: $("#popup_title") });
$("#popup_title").css({ cursor: 'move' });
} catch(e) { /* requires jQuery UI draggables */ }
}
},
}
// Shortuct functions
jAlert = function(message, title, modified, callback) {
$.alerts.alert(message, title, modified, callback);
}
jConfirm = function(message, title, callback) {
$.alerts.confirm(message, title, callback);
};
})(jQuery);
htlm中的呼叫代码:
call code in htlm:
function changeNext()
{
jAlert('Serial number is not submitted', 'Error Message', 'true');
}
预先感谢.
Thank in advance.
推荐答案
这篇关于如何使用jQuery更改警报消息的按钮文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!