Node.js HTML5 application - sending a URL parameter

hindersaliva
hindersaliva used Ask the Experts™
on
I'm trying to understand how this works so that I can make a few small tweeks.
https://github.com/squallooo/MT5

When the page opens a dropdown list is populated, and a song selection can be made.
I can see that a Function loadSong(songName) { ...} is fired off at that point. (it is in sounds.js)

I have found that I can force the song by doing this on line 342
currentSong = new Song("Londres Appelle", context);

Open in new window

"Londres Appelle" is a song in the demo list.

My question is, would it be possible to force a 'song' in this function by using a URL parameter?
eg.
http://www.mydomain.com/index.html?songName="Londres Appelle"

My background: JavaScript and Node.js newbie. Worked extensively with Classic ASP and VBScript back in the day  (2001-2003). I understand using QueryString to pass a variable to a page, but I don't know if I need to think differently in Node.js.

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
OK. I've dug bit deeper . A simpler question.

I found this.
<script type="text/javascript">
        //This is from https://stackoverflow.com/questions/6912584/how-to-get-get-query-string-variables-in-express-js-on-node-js
        
        var express = require('express');
        var app = express();
        
        app.get('/', function(req, res){
        res.send('id: ' + req.query.id);
        });

        app.listen(3000)
        
    </script>

    <script>
           window.alert("Hi there!")
    </script>

Open in new window


I can move further if I can make the alert show me the string in the URL parameter.
So if I run
localhost:3000?id=Micky

Open in new window

I want the alert to say 'Micky'

Can someone show me the way please?

Author

Commented:
I guess Node.js is not  that mainstream yet?

Author

Commented:
I don't want to DELETE the question, as I may want to refer to it later or re-ask the question.
What shall I do? Can the question just remain here?

Author

Commented:
Looks like I'm the only one in this conversation!

I've now decided to learn Node.js. I should have started there!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial