Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7024005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:47:01+00:00 2026-05-27T23:47:01+00:00

I would like to send some parameters to my desktop notification but i can’t

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:47:02+00:00Added an answer on May 27, 2026 at 11:47 pm

    The Query String is not setup to be parsed easily with JS. Do you only need to pass one String?

    If so, use the Hash instead of the Query String:

    var notification = webkitNotifications.createHTMLNotification('../html/notification.html#' + nb);
    

    Then in notification.js:

    $('#message span').html(window.location.hash.substr(1) + ' nouveau message');
    

    If you need to pass more than one variable, you can use a Stringified JSON object:

    var data = {
            var1: "somedata",
            var2: 12345
        },    
        notification = webkitNotifications.createHTMLNotification('../html/notification.html#' + JSON.stringify(data));
    

    Then in notification.js:

    var data = JSON.parse(window.location.hash.substr(1));
    $('#message span').html('var1 is ' + data.var1 + ' var2 is' + data.var2);
    

    If you get parse errors you may have to use encodeURIComponenet() and decodeURIComponent()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to send out an update of my apk, but i did
I would like to send a html string with a GET request like this
I would like to send and receive OpenSoundControl in an AIR application, on the
I would like to send a list of Appointment s through WCF. My Interface
I would like to send a struct from my client program to a server
I'm using a Rails application and would like to send/receive text messages through my
I have a window which is hidden and I would like to send a
I have a byte[] with the contents of file. I would like to send
I use ancestry to make a tree of goals. I would like to send
I would like to know how to send a post request in curl and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.