Click here to Skip to main content
12,508,992 members (52,875 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Javascript jQuery
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);

call code in htlm:
function changeNext()
        {
 
            jAlert('Serial number is not submitted', 'Error Message', 'true');
        }

Thank in advance.
Posted 31-Jul-12 1:28am
ngthtra1.4K
Updated 31-Jul-12 15:54pm
v2
Comments
ryanb31 31-Jul-12 8:38am
   
This is way too much code for my brain to go through. Can you simplify your question down to just the necessary parts?
ngthtra 31-Jul-12 22:02pm
   
ok, I removed code that unnecessary, you can help me find out reason,please.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I don't see the word 'back' in your code, but, the jAlert library works perfectly, I use it all the time. However, the OK button is a graphic. You need to figure out where the library gets that graphic from ( you can right click on it in the browser and see where it points ) and change it to a graphic that says 'back', if that's what you want. Supporting different graphics for different messages would be an addition to this library.
  Permalink  
Comments
ngthtra 31-Jul-12 22:00pm
   
work 'back' in my code is a parameter onButton1. and my code flow as following: call JAlert() -> call alert() -> call show().I used para modified to change text of button, if modified = 'true' => used "back" else used "OK". But this code don't run and Why I don't know.
Christian Graus 31-Jul-12 22:03pm
   
You can view source in Chrome and step through your javascript to see what is going wrong. I don't see any examples that indicate that these buttons support what you want, but if they do, then you can debug to see where it's going wrong.
ngthtra 8-Aug-12 5:28am
   
I resolved this problem. thanks evryone

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 31 Jul 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100