I would like to send some parameters to my desktop notification but i can't retrieve them.
I open a notification with that code :
var notification = webkitNotifications.createHTMLNotification(
'../html/notification.html?data='+nb
);
Where nb is my variable.
notification.html :
<!DOCTYPE html>
<html>
<head>
<title>Notification</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="../js/notification.js"></script>
</head>
<body>
<div id="message">Vous avez <span></span></div>
</body>
</html>
notification.js :
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var first = getUrlVars()['data'];
$('#message span').html(first +' nouveau message');
The result is "Vous avez" instead of "Vous avez 1 nouveau message" for example.
I checked if my notification.js is loaded. How to check the value of "first"? How to debug that JS code? Or have you a better method to retrieve GET parameters in URL?
Thank's a lot.
Regards