6
[GopherJS] window.location - Access URL
source link: http://siongui.github.io/2017/01/02/gopherjs-window-location-access-url/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[GopherJS] window.location - Access URL
January 02, 2017
Access URL, path, query string, etc. of current URL via window.location and GopherJS.
import "github.com/gopherjs/gopherjs/js" var location = js.Global.Get("location") func accessURL() { // current URL: http://localhost:8000/code/gopherjs/window-location/index.html?a=1 // return - http://localhost:8000/code/gopherjs/window-location/index.html?a=1 location.Get("href").String() // return - localhost:8000 location.Get("host").String() // return - localhost location.Get("hostname").String() // return - /code/gopherjs/window-location/index.html location.Get("pathname").String() // return - http: location.Get("protocol").String() // return - http://localhost:8000 location.Get("origin").String() // return - 8000 location.Get("port").String() // return - ?a=1 location.Get("search").String() }
For JavaScript equivalent, see [2].
Tested on:
- Ubuntu Linux 16.10
- Go 1.7.4
- Chromium Version 55.0.2883.87 Built on Ubuntu , running on Ubuntu 16.10 (64-bit)
References:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK