I am using Drupal 7.
In the template file
page.tpl.php there is a variable called
$message which prints the messages like error, warning etc.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
In your page.tpl.php file:
$my_settings = array( 'message' => $message, ); drupal_add_js(array('my_settings' => $my_settings), 'setting');
$message variable like this:
var message = Drupal.settings.my_settings.message;