Location[(string | variable)]
Description
Location lets you get or set the name of the current app. It will return the URL of the current app that you are running. If you want to run another app or go to a web page, assign the URL of that app to Location. In this respect, it works similarly to the Chain statement found in some other implementations of BASIC.
To send parameters to the next app, put a question mark (?) followed by the string after the new app name.
Properties and Methods
hash |
Sets or returns the anchor part (#) of a URL
|
host |
Sets or returns the hostname and port number of a URL
|
hostname |
Sets or returns the hostname of a URL
|
href |
Sets or returns the entire URL
|
origin |
Returns the protocol, hostname and port number of a URL
|
pathname |
Sets or returns the path name of a URL
|
port |
Sets or returns the port number of a URL
|
protocol |
Sets or returns the protocol of a URL
|
search |
Sets or returns the querystring part of a URL
|
assign() |
Loads a new document
|
reload() |
Reloads the current document
|
replace() |
Replaces the current document with a new one
|
Example
// Location Example
NSB.MsgBox("The name of this app is " + location);
NSB.MsgBox("Going to http://www.nsbasic.com/Project1/index.html?someParameters");
location = "http://www.nsbasic.com/Project1/index.html?someParameters";
// PROJECT1
NSB.MsgBox("Started with parameter " & location.search);
Rem Location Example
MsgBox "The name of this app is " & location
MsgBox "Going to http://www.nsbasic.com/Project1/index.html?someParameters"
location = "http://www.nsbasic.com/Project1/index.html?someParameters"
Rem PROJECT1
MsgBox "Started with parameter " & location.search
</syntaxhighlight>
Send your own query string (instead of Form Submit())
location.href="http://someurl.com/index.html?parameter1=one¶meter2=two"
Open a web page:
location.href = "http://news.google.com"
Open the Phone app:
document.location.href = "tel:+1-800-555-1234"
Read the query string which was passed to your app
queryParams = location.search
Output
?someParameters