How to get web server name
I'm completely out of my depth here. I'm trying to find a way for a BBC BASIC program, running in the in-browser edition of BBCSDL, to discover from where bbcsdl.html was downloaded.
For example, it needs to be able to tell whether it was run as https://wasm.bbcbasic.co.uk/bbcsdl.html or https://wasm.bbcbasic.net/bbcsdl.html. I feel that should be possible, but haven't a clue how to achieve it.
The only thing Google has come up with is this StackOverflow post, but I don't know how to apply it.
For example, it needs to be able to tell whether it was run as https://wasm.bbcbasic.co.uk/bbcsdl.html or https://wasm.bbcbasic.net/bbcsdl.html. I feel that should be possible, but haven't a clue how to achieve it.
The only thing Google has come up with is this StackOverflow post, but I don't know how to apply it.
0
Comments
-
it appears that code snippet retrieves the detail
The easiest language to use would probably be JavaScript, because I can call that from BBC BASIC code quite straightforwardly:SYS "emscripten_run_script", script$
0 -
Richard_Russell wrote: »
SYS "emscripten_run_script", script$
SYS "emscripten_run_script_string", script$ TO host% host$ = $$host%
So if there's a way to get the server name in JavaScript this should do the job nicely. But is there?
0 -
Does this help?
But the top-rated reply seems to be talking about how to extract the hostname of the current page's URL, which isn't what the questioner is asking for, but is what I need!
The missing link is that I don't know how to write JavaScript code to return the wanted 'property' as a string. Maybe it's as simple as this (that would be nice!) but I'll have to try it to find out:SYS "emscripten_run_script_string", "window.location.hostname" TO host% host$ = $$host%
0 -
Richard_Russell wrote: »Maybe it's as simple as this (that would be nice!)
Thanks very much for the pointer (and to Darren Storer at the Discussion Group).
1 -
Nice one! Out of curiosity, what does $$var% do (specifically, the double $) ?0
-
Out of curiosity, what does $$var% do (specifically, the double $) ?
I expect RISC OS uses CR-terminated strings, but if so it's an outlier.0