(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: .40, // 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案文取消按钮
dialogClass: null, // if specified, this class will be applied to all dialogs 如果指定,这个类 // Public methods alert: function(message, title, callback) {
if (title == null) title = 'Alert';
$.alerts._show(title, message, null, 'alert', function(result) {
if (callback) callback(result);
});
}, confirm: function(message, title, callback) {
if (title == null) title = 'Confirm';
$.alerts._show(title, message, null, 'confirm', function(result) {
if (callback) callback(result);
});
}, prompt: function(message, value, title, callback) {
if (title == null) title = 'Prompt';
$.alerts._show(title, message, value, 'prompt', function(result) {
if (callback) callback(result);
});
}, // Private methods _show: function(title, msg, value, type, 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_container").css({
position: pos,
zIndex: 99999,
padding: 0,
margin: 0
}); $("#popup_title").text(title);
$("#popup_content").addClass(type);
//$("#popup_content").ClassName = 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);
alert(escape($.alerts.okButton));
这是一个Jquery Alert 插件里面的代码,我修改了些东西,却发现有些小问题。。请看红色字体,为什么定义OK Cancel的时候没问题。而为中文“确定”“取消”的时候就是乱码,显示不了,我也试了escape和unescape都没有用希望有牛人解释
horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/横向偏移从
repositionOnResize: true, // re-centers the dialog on window resize重新中心的窗口对话框中调整
overlayOpacity: .40, // 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案文取消按钮
dialogClass: null, // if specified, this class will be applied to all dialogs 如果指定,这个类 // Public methods alert: function(message, title, callback) {
if (title == null) title = 'Alert';
$.alerts._show(title, message, null, 'alert', function(result) {
if (callback) callback(result);
});
}, confirm: function(message, title, callback) {
if (title == null) title = 'Confirm';
$.alerts._show(title, message, null, 'confirm', function(result) {
if (callback) callback(result);
});
}, prompt: function(message, value, title, callback) {
if (title == null) title = 'Prompt';
$.alerts._show(title, message, value, 'prompt', function(result) {
if (callback) callback(result);
});
}, // Private methods _show: function(title, msg, value, type, 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_container").css({
position: pos,
zIndex: 99999,
padding: 0,
margin: 0
}); $("#popup_title").text(title);
$("#popup_content").addClass(type);
//$("#popup_content").ClassName = 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);
alert(escape($.alerts.okButton));
这是一个Jquery Alert 插件里面的代码,我修改了些东西,却发现有些小问题。。请看红色字体,为什么定义OK Cancel的时候没问题。而为中文“确定”“取消”的时候就是乱码,显示不了,我也试了escape和unescape都没有用希望有牛人解释
解决方案 »
- JS代码精简
- <a title="qwe">标签里 加onclick ,点击则在一个input里显示出qwe来,怎么搞?
- jquery 如何定义全局变量 global吗?
- 求助:js里如何实现 html 中 onSubmit="return myOnSubmit();"这样的函数调用功能!
- 怎么通过2个输入框来计算出第三个输入框的日期
- javascript执行过程较长,能否在其执行过程中显示进度?
- 求一个JAVASCRIPT正则表达式,高手请帮忙啊
- url如何加密,我做的是静态页面,a页面把视频地址传递给B页面,穿过去的地址如何加密,然后在B页面里解密,播放。谢谢!!!!
- javascript 关于uri地址中含有%的处理方式?
- jQuery读取txt文档并用javascript处理的问题
- 有没有办法根据当前系统日期自动调整日期下拉框的值
- 《javascript权威指南》买哪个版本的好。
horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/横向偏移从
repositionOnResize: true, // re-centers the dialog on window resize重新中心的窗口对话框中调整
overlayOpacity: .40, // 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案文取消按钮
dialogClass: null, // if specified, this class will be applied to all dialogs 如果指定,这个类 // Public methods alert: function(message, title, callback) {
if (title == null) title = 'Alert';
$.alerts._show(title, message, null, 'alert', function(result) {
if (callback) callback(result);
});
}, confirm: function(message, title, callback) {
if (title == null) title = 'Confirm';
$.alerts._show(title, message, null, 'confirm', function(result) {
if (callback) callback(result);
});
}, prompt: function(message, value, title, callback) {
if (title == null) title = 'Prompt';
$.alerts._show(title, message, value, 'prompt', function(result) {
if (callback) callback(result);
});
}, // Private methods _show: function(title, msg, value, type, 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_container").css({
position: pos,
zIndex: 99999,
padding: 0,
margin: 0
}); $("#popup_title").text(title);
$("#popup_content").addClass(type);
//$("#popup_content").ClassName = 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);
alert(escape($.alerts.okButton));
这是一个Jquery Alert 插件里面的代码,我修改了些东西,却发现有些小问题。。请看红色字体,为什么定义OK Cancel的时候没问题。而为中文“确定”“取消”的时候就是乱码,显示不了,我也试了escape和unescape都没有用希望有牛人解释
okButton: ' 确定 ', // text for the OK button文本确定按钮
cancelButton: ' Cancel ', // text for the Cancel
$.alerts._reposition();
$.alerts._maintainPosition(true);
alert(escape($.alerts.okButton));
把【取消】替换为 取消
试试看!
怎么保存为这个格式。。?
例如:【确】的 escape 编码为 %u786E,而 786E 的十进制就是 30830,再加上 &# 就可以了!这招只在国外网站上学来的,他们在显示中文时就这做!
function HTMLbm(code){
var _s="";
for(var i=0;i<code.length;i++){
_s+="&#"+code.charCodeAt(i);
}
return _s;
}var str=HTMLbm("hello,你好");
document.write(str);
alert(str);