browser

package
v0.1.6-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CookieEnabled

func CookieEnabled() bool

CookieEnabled eturns a Boolean value that indicates whether cookies are enabled or not.

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/cookieEnabled

func Language

func Language() string

Language returns a string representing the preferred language of the user, usually the language of the browser UI.

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language

func OnLine

func OnLine() bool

OnLine Returns the online status of the browser.

The property returns a boolean value, with true meaning online and false meaning offline. The property sends updates whenever the browser's ability to connect to the network changes. The update occurs when the user follows links or when a script requests a remote page. * For example, the property should return false when users click links soon after they lose internet connection.

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine

func UserAgent

func UserAgent() string

UserAgent returns the user agent string for the current browser.

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent

Types

type HISTORY_SCROLL_RESTORATION

type HISTORY_SCROLL_RESTORATION string
const (
	HISTORY_SR_AUTO   HISTORY_SCROLL_RESTORATION = "auto"
	HISTORY_SR_MANUAL HISTORY_SCROLL_RESTORATION = "manual"
)

type History

type History struct {
	js.JSValue
}

The DOM Window object provides access to the browser's session history (not to be confused for WebExtensions history) through the history object. It exposes useful methods and properties that let you navigate back and forth through the user's history, and manipulate the contents of the history stack.

https://developer.mozilla.org/en-US/docs/Web/API/History

func SessionHistory

func SessionHistory() *History

History returning attribute 'history' with type htmlmisc.History (idl: History).

https://developer.mozilla.org/en-US/docs/Web/API/Window/history

func (*History) Back

func (_this *History) Back()

causes the browser to move back one page in the session history.

https://developer.mozilla.org/en-US/docs/Web/API/History/back

func (*History) Count

func (_this *History) Count() int

Length eturns an integer representing the number of elements in the session history, including the currently loaded page.

https://developer.mozilla.org/en-US/docs/Web/API/History/length

func (*History) Forward

func (_this *History) Forward()

causes the browser to move forward one page in the session history. It has the same effect as calling history.go(1).

https://developer.mozilla.org/en-US/docs/Web/API/History/forward

func (*History) Go

func (_this *History) Go(delta int)

Go Loads a specific page from the session history. You can use it to move forwards and backwards through the history depending on the value of a parameter.

This method is asynchronous. Add a listener for the popstate event in order to determine when the navigation has completed.

https://developer.mozilla.org/en-US/docs/Web/API/History/go

func (*History) PushState

func (_this *History) PushState(data interface{}, url *url.URL)

PushState adds an entry to the browser's session history stack.

https://developer.mozilla.org/en-US/docs/Web/API/History/pushState

func (*History) ReplaceState

func (_this *History) ReplaceState(data interface{}, url *url.URL)

modifies the current history entry, replacing it with the state object and URL passed in the method parameters. This method is particularly useful when you want to update the state object or URL of the current history entry in response to some user action.

https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState

func (*History) ScrollRestoration

func (_this *History) ScrollRestoration() HISTORY_SCROLL_RESTORATION

ScrollRestoration allows web applications to explicitly set default scroll restoration behavior on history navigation.

https://developer.mozilla.org/en-US/docs/Web/API/History/scrollRestoration

func (*History) SetScrollRestoration

func (_this *History) SetScrollRestoration(value HISTORY_SCROLL_RESTORATION)

ScrollRestoration allows web applications to explicitly set default scroll restoration behavior on history navigation.

https://developer.mozilla.org/en-US/docs/Web/API/History/scrollRestoration

func (*History) State

func (_this *History) State() js.JSValue

State returns a value representing the state at the top of the history stack. This is a way to look at the state without having to wait for a popstate event.

The value is null until the pushState() or replaceState() method is used.

TODO: browser - handle History.State returned value

https://developer.mozilla.org/en-US/docs/Web/API/History/state

type Storage

type Storage struct {
	js.JSValue
	// contains filtered or unexported fields
}

https://developer.mozilla.org/fr/docs/Web/API/Web_Storage_API

func LocalStorage

func LocalStorage() *Storage

allows you to access a Storage object for the Document's origin; the stored data is saved across browser sessions.

returns nil if access is denied to the localstorage

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

func SessionStorage

func SessionStorage() *Storage

accesses a session Storage object for the current origin.

sessionStorage is similar to localStorage; the difference is that while data in localStorage doesn't expire, data in sessionStorage is cleared when the page session ends.

https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

func (*Storage) At

func (_store *Storage) At(_idx int) string
returns the name of the nth key in a given Storage object. The order of keys is user-agent defined, so you should not rely on it.

https://developer.mozilla.org/en-US/docs/Web/API/Storage/key

func (*Storage) Clear

func (_store *Storage) Clear()

clears all keys stored in a given Storage object.

https://developer.mozilla.org/en-US/docs/Web/API/Storage/clear

func (*Storage) Count

func (_store *Storage) Count() int

Length returns the number of data items stored in a given Storage object.

returns -1 if the storage object is nil

https://developer.mozilla.org/en-US/docs/Web/API/Storage/length

func (*Storage) Get

func (_store *Storage) Get(key string) (_value string)

when passed a key name, will return that key's value, or null if the key does not exist, in the given Storage object.

https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem

func (*Storage) GetBool

func (_store *Storage) GetBool(key string) (_value bool)

return true if the key exists and the value is not "false" nor "0"

func (*Storage) GetInt

func (_store *Storage) GetInt(key string) (_value int)

convert the returned value in int. returns 0 if the key does not exists

func (*Storage) Remove

func (_store *Storage) Remove(key string)

when passed a key name, will remove that key from the given Storage object if it exists. The Storage interface of the Web Storage API provides access to a particular domain's session or local storage.

https://developer.mozilla.org/en-US/docs/Web/API/Storage/removeItem

func (*Storage) Set

func (_store *Storage) Set(key string, value string) error

when passed a key name, will return that key's value, or null if the key does not exist, in the given Storage object.

https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem TODO: browser - handle Storage error

type Window

type Window struct {
	js.JSValue // embedded js.JSValue
	// contains filtered or unexported fields
}

Window

https://developer.mozilla.org/en-US/docs/Web/API/Window

func CastWindow

func CastWindow(_jsv js.JSValueProvider) Window

CastWindow is casting a js.JSValue into Window.

func Win

func Win() Window

GetWindow returning attribute 'window' with type Window (idl: Window).

func (Window) AddBeforeUnloadEvent

func (_win Window) AddBeforeUnloadEvent(_listener func(*event.BeforeUnloadEvent, *Window))

func (Window) AddGenericEvent

func (_win Window) AddGenericEvent(evttype event.GENERIC_EVENT, _listener func(*event.Event, *Window))

func (Window) AddHashChangeEvent

func (_win Window) AddHashChangeEvent(_listener func(*event.HashChangeEvent, *Window))

AddHashChange is adding doing AddEventListener for 'HashChange' on target. This method is returning allocated javascript function that need to be released.

func (Window) AddPageTransitionEvent

func (_win Window) AddPageTransitionEvent(evttype event.PAGETRANSITION_EVENT, _listener func(*event.PageTransitionEvent, *Window))

func (Window) AddResizeEvent

func (_win Window) AddResizeEvent(_listener func(*event.UIEvent, *Window))

func (Window) Alert

func (_win Window) Alert(message string)

instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.

https://developer.mozilla.org/en-US/docs/Web/API/Window/alert

func (Window) Blur

func (_win Window) Blur()

Shifts focus away from the window.

https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event

func (Window) Close

func (_win Window) Close()

method closes the current window, or the window on which it was called.

https://developer.mozilla.org/en-US/docs/Web/API/Window/close

func (Window) Closed

func (_win Window) Closed() bool

Closed ndicates whether the referenced window is closed or not.

https://developer.mozilla.org/en-US/docs/Web/API/Window/closed

func (Window) DevicePixelRatio

func (_win Window) DevicePixelRatio() float64

DevicePixelRatio returns the ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device. https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio

func (Window) Display

func (_win Window) Display(url url.URL)

Load and Display the provided URL.

The difference from the Navigate() method is that the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it.

https://developer.mozilla.org/en-US/docs/Web/API/Location/replace

func (Window) Focus

func (_win Window) Focus()

Makes a request to bring the window to the front. It may fail due to user settings and the window isn't guaranteed to be frontmost before this method returns.

https://developer.mozilla.org/en-US/docs/Web/API/Window/focus

func (Window) InnerSize

func (_win Window) InnerSize() (_width int, _height int)

InnerWidth returns the interior width of the window in pixels. This includes the width of the vertical scroll bar, if one is present.

https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth

func (Window) Navigate

func (_win Window) Navigate(url url.URL)

Navigate to the provided URL. (aka. js Assign)

After the navigation occurs, the user can navigate back by pressing the "back" button.

https://developer.mozilla.org/en-US/docs/Web/API/Location/assign

func (Window) Open

func (_win Window) Open(url *url.URL, target string) Window

Loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.

The special target keywords, _self, _blank, _parent, and _top, can also be used.

https://developer.mozilla.org/en-US/docs/Web/API/Window/open

func (Window) OuterSize

func (_win Window) OuterSize() (_width int, _height int)

OuterWidth returning attribute 'outerWidth' with

func (Window) Print

func (_win Window) Print()

Opens the print dialog to print the current document.

https://developer.mozilla.org/en-US/docs/Web/API/Window/print

func (Window) Reload

func (_win Window) Reload()

Reloads the current URL, like the Refresh button.

func (*Window) RemoveListeners

func (_win *Window) RemoveListeners()

Release need to be called only when avent handlers have been added to the Event-target. Release removes all event listeners and release ressources allocated fot the associated js func

func (Window) ScrollPos

func (_win Window) ScrollPos() (_x float64, _y float64)

ScrollX returns the number of pixels that the document is currently scrolled horizontally. This value is subpixel precise in modern browsers, meaning that it isn't necessarily a whole number. You can get the number of pixels the document is scrolled vertically from the scrollY property.

https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX

func (Window) Stop

func (_win Window) Stop()

stops further resource loading in the current browsing context, equivalent to the stop button in the browser.

https://developer.mozilla.org/en-US/docs/Web/API/Window/stop

func (Window) URL

func (_win Window) URL() *url.URL

extract the URL object from the js Location

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL