Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with alert

Hi,
I came across this code for adding an alert from this link, http://stackoverflow.com/questions/94...
I cant get this to work, I running the code on click

can you see anything wrong, I need to have alerts without the pagename on the alert title

thx

codefunction showMessage(message, callback, title, buttonName){

Code: Select all

 title = title || "default title&quot 
 buttonName = buttonName || 'OK'; 

 if(navigator.notification && navigator.notification.alert){ 

     navigator.notification.alert( 
         message,    // message 
         callback,   // callback 
         title,      // title 
         buttonName  // buttonName 
     ); 

 }else{ 

     alert(message); 
     callback(); 
 } 

}/code

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

problem with alert

Hello!
Your code works for us.
Could you clarify what device/OS version you use to test? Are title and button caption set? Could you post the screenshot?

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with alert

Hi Maryna,
I have misunderstood the implementation of this code, I have just copied it and used it on a click event, I added my title and message but its wrong.
I thought the settings were in the code
this is the code and it will explain of how I thought it could be used

thx

codefunction showMessage(message, callback, title, buttonName){

Code: Select all

 title = title || "Cart&quot 
 buttonName = buttonName || 'OK'; 

 if(navigator.notification && navigator.notification.alert){ 

     navigator.notification.alert( 
         message,    // message 
         callback,   // callback 
         title,      // title 
         buttonName  // buttonName 
     ); 

 }else{ 

     alert(Added To Your Order); 
     callback(); 
 } 

}/code

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with alert

sorry Maryna, forgot to say,
testing in browser as this code is supposed to work for web and phonegap apps

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

problem with alert

Create JS asset with your code and on click event run this code preshowMessage("message text", function(){}, "title", "buttonName");/prePlease note in browser there will be ordinary alert.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with alert

Hi Maryna,
I dine that but I got an error in console, here is the s/s of the js and the error

Image

Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

problem with alert

Replace prealert(Added To Your Order);/pre with prealert("Added To Your Order");/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

problem with alert

Great Maryna,
thx very much, I am very grateful as I am aware js is not within the support remit,
best support there is!

cheers

Return to “Issues”