Retrive $message variables in javascript file
In your page.tpl.php file:

$my_settings = array(
  'message' =&gt; $message,
);

drupal_add_js(array('my_settings' =&gt; $my_settings), 'setting');


Then in your JavaScript file you can access $message variable like this:

var message = Drupal.settings.my_settings.message;


Reference: The Drupal JavaScript API