HTML5 AppArgs

Monkey Forums/Monkey Code/HTML5 AppArgs

k.o.g.(Posted 2014) [#1]
#If TARGET<>"html5"
 Import os
#Else
 Extern
  Global _search:String="(window.location.search || ~q~q)"
  Global _hash:String="(window.location.hash || ~q~q)"
 Public
 
  Function AppArgs:String[]()
   Local hash:String = _hash[1..]
   Local search:String = _search[1..]
   Local args:String[]

   If search.Length()>0
    args = search.Split("&")
   Else If hash.Length()>0
    args = hash.Split("&")
   End 
   
   Return args
  end
#end


Example:
http://url/MonkeyGame.html?test=1&start=here

Or

http://url/MonkeyGame.html#test=1&start=here


degac(Posted 2014) [#2]
Thanks!
This seems really useful !


Paul - Taiphoz(Posted 2014) [#3]
could be used for passing in coupon or codes to reward people with stuff in game, like hay all here is a free rocket launcher code for gameX ROCKET11111 could do little promotions to promote people to play more, could also be used for metrics and some ... other .. stuff.


Hezkore(Posted 2014) [#4]
The DOM module also has the window.location stuff.


k.o.g.(Posted 2014) [#5]
Yea thats true, but i don't want import the complete dom module for that ;)


ElectricBoogaloo(Posted 2014) [#6]
Voucher codes?! Crunch some data, and URL-a-size entire levels!!
Thanks, I'll be making good use of this :D