How To Pass/Read Parameters To/From Html5 ?

Monkey Targets Forums/HTML5/How To Pass/Read Parameters To/From Html5 ?

semar(Posted 2013) [#1]
All,
I need a way to pass a parameter to an HTML5 application which should read it, is there any way to accomplish this task ?

Like a php script that reads the parameter with $_GET["myVar"], I would be able to read a parameter like so:

www.xyz/monkeygame.html?myVar=123

and read it from within the monkeygame.html app.

Is that possible ? I've read something about the JavaScript window.location.search function.. how to implement it using the Extern statement in Monkey ?

Thanks in advance,
Sergio.


DruggedBunny(Posted 2013) [#2]
Try this:


Import "external.js"

Extern
	Global PageURL:String
	
Public

Function Main ()

	#If TARGET="html5"

		' Print URL:
		
		Print PageURL
		
		' Print URL after ?
		
		' Add ?YourParameter to end of URL and go again!
		
		Print PageURL [PageURL.Find ("?") + 1..] ' Preferred Mid ()!

	#Endif
	
End


Open another tab, paste this in, and save in the same folder as "external.js"...

var PageURL=document.URL;


In fact, here it is online:

http://www.hi-toro.com/monkey/externjs/external.html

Just add ?YourParameter to the end of the URL, eg.

http://www.hi-toro.com/monkey/externjs/external.html?HelloWorld


skid(Posted 2013) [#3]
This may also prove useful:

Import dom

Function Main()
	Print "window.location.href="+window.location.href
End



semar(Posted 2013) [#4]
Fantastic, exactly what I need, thank you mates :-))


DruggedBunny(Posted 2013) [#5]
Forgot about 'dom'! Handy, since I've recently been trying to pick up html/css/js, etc all over again. Will have to investigate...