check url

Monkey Targets Forums/HTML5/check url

Yoda(Posted 2011) [#1]
How to check which url the app is running?


skape(Posted 2011) [#2]
How do you check what the URL of the page is?

You can quickly get the server's domain with document.domain or the URL with document.URL using the DOM module... That's one way anyway.


impixi(Posted 2011) [#3]



Samah(Posted 2011) [#4]
This is a more platform-agnostic way to do it:


Obviously this should be filled in with code for Flash.
function (){return ExternalInterface.call(~qwindow.location.href.toString~q);}

But this requires ExternalInterface to be imported.

--------------------

Edit: GetCurrentURL() added to Diddy r321 for HTML and Flash.


Yoda(Posted 2011) [#5]
Extern
Function getCurrentURL:String() = "function (){return document.URL;}"
Public

That gives me an error: Missing return expression.


therevills(Posted 2011) [#6]
That gives me an error: Missing return expression.

Strange... that works fine here. What version of Monkey are you using?

Try just copying and pasting impixi's example:
Strict

Extern
	Function getCurrentURL:String() = "function (){return document.URL;}"
Public

Function Main:Int()
	Print getCurrentURL()
	Return 0
End



impixi(Posted 2011) [#7]
Is that error in Monkey or in the browser? If it's a Monkey error, you may have forgotten the Return 0 statement in the Main function. Strict mode requires it.