Location

The location object contains information about the current URL.

The location object is part of the window object and is accessed through the window.location property.

Related Pages:

https//www.w3schools.com/jsref/obj_location.asp

class epyk.core.js.JsLocation.JsLocation

JavaScript Location module.

classmethod assign(url: Union[str, JsDataModel]) JsFunction

The assign() method loads a new document.

Related Pages:

https//www.w3schools.com/jsref/met_loc_assign.asp

Parameters:

url – Specifies the URL of the page to navigate to

classmethod download(url: Union[str, JsDataModel], name: Union[str, JsDataModel] = 'download') JsVoid

Download data from the url.

Parameters:
  • url – The url of the image

  • name – Optional. The name of the file

classmethod getUrlFromArrays(data: Union[list, JsDataModel], delimiter: Union[str, JsDataModel] = ',', charset: str = 'utf-8', end_line: Union[str, JsDataModel] = '\r\n')

Convert data to a URL.

Parameters:
  • data – A JavaScript array

  • delimiter – Optional. The column delimiter

  • charset – Optional.

  • end_line – Optional.

classmethod getUrlFromData(data: Union[dict, JsDataModel], options: Optional[Union[dict, JsDataModel]] = None)

Convert data to a URL.

Related Pages:

Parameters:
  • data – Input data to be converted

  • options – Optional. Blob definition properties

property hash: JsObject

The hash property sets or returns the anchor part of a URL, including the hash sign (#).

Usage:

jsObj.location.hash

Related Pages:

https//www.w3schools.com/jsref/prop_loc_hash.asp

Returns:

A String, representing the anchor part of the URL, including the hash sign (#).

property host: JsString

The host property sets or returns the hostname and port of a URL.

Usage:

jsObj.location.host

Related Pages:

https//www.w3schools.com/jsref/prop_loc_host.asp

Returns:

Return the hostname and port of the current URL.

property hostname: JsString

The hostname property sets or returns the hostname of a URL.

Usage:

page.location.hostname

Related Pages:

https//www.w3schools.com/jsref/obj_location.asp

Returns:

Return the hostname property.

classmethod href(href: Optional[Union[JsDataModel, str]] = None, secured: bool = False) JsObject

The href property sets or returns the entire URL of the current component.

Usage:

page.js.location.href("https://www.w3schools.com/howto/howto_js_fullscreen.asp")

Related Pages:

Parameters:
  • href – Optional. Set the href property

  • secured – Optional. The secured flag

Returns:

A String, representing the entire URL of the page, including the protocol (like http://).

mail(mails: List[str], subject: str, body: str)

The mailto link when clicked opens users default email program or software. A new email page is created with “To” field containing the address of the name specified on the link by default.

Usage:

page.js.location.mail(["test@gmail.com"], "This is a test", "This is the email's content")

Related Pages:

Parameters:
  • mails – The email addresses

  • subject – The email’s subject

  • body – The email’s content

Returns:

THe Javascript string.

classmethod open_new_tab(url: Union[str, JsDataModel], name: Union[str, JsDataModel] = '_blank', specs: Optional[Union[JsDataModel, str]] = None, replace: Optional[Union[JsDataModel, str]] = None, window_id: str = 'window', data: Optional[dict] = None, secured: bool = False) JsFunction

Opens a new browser window in a new tab (duplicated but part of the Window module).

Usage:

page.js.location.open_new_tab("www.google.fr")

Related Pages:

Parameters:
  • url – Optional. Specifies the URL of the page to open. If no URL is specified, a new window/tab with about:blank is opened

  • name – Optional. Specifies the target attribute or the name of the window. Default _blank

  • specs – Optional. A comma-separated list of items, no whitespaces

  • replace – Optional. Specifies whether the URL creates a new entry or replaces the current entry in the history list

  • window_id – Optional. The JavaScript window object

  • data – Optional. The url parameters

  • secured – Optional. The secure flag

property origin: JsString

The origin property returns the protocol, hostname and port number of a URL.

Usage:

page.js.location.origin + page.js.location.pathname

Related Pages:

https//www.w3schools.com/jsref/prop_loc_origin.asp

Returns:

A String, representing the protocol (including ://), the domain name (or IP address) and port number (including the colon sign (:) of the URL. For URL’s using the “file:” protocol, the return value differs between browser)

property pathname: JsString

The hostname property sets or returns the hostname of a URL.

Usage:

jsObj.location.pathname

Related Pages:

https//www.w3schools.com/jsref/obj_location.asp

Returns:

Return the pathname property.

property port: JsString

The port property sets or returns the port number the server uses for a URL.

Related Pages:

https//www.w3schools.com/jsref/prop_loc_port.asp

Returns:

A String, representing the port number of a URL.

classmethod postTo(url: str, data: dict, method: str = 'POST', target: str = '_blank')

This method will create an internal form and submit the response exactly like a post of a form to another page.

Related Pages:

Parameters:
  • url – The target url

  • data – The url parameters

  • method – Optional. The method used to send the data. Default POST

  • target – Optional. Target method to access the new page

classmethod reload(force_get: bool = False)

The reload() method is used to reload the current document.

The reload() method does the same as the reload button in your browser.

Related Pages:

https//www.w3schools.com/jsref/met_loc_reload.asp

Parameters:

force_get – Optional. Specifies the type of reloading: false - Default. Reloads the current page from the cache true - Reloads the current page from the server

classmethod replace(url: Union[str, JsDataModel], secured: bool = False) JsFunction

The replace() method replaces the current document with a new one.

The difference between this method and assign(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the “back” button to navigate back to the original document.

Related Pages:

https//www.w3schools.com/jsref/met_loc_replace.asp

Parameters:
  • url – Specifies the URL of the page to navigate to

  • secured – Optional. If the http is missing. This will be used to fix the url

property search: JsString

The search property sets or returns the querystring part of a URL, including the question mark (?).

Related Pages:

https//www.w3schools.com/jsref/prop_loc_search.asp

Returns:

A String, representing the querystring part of a URL, including the question mark (?).

url(params: Optional[Union[dict, JsDataModel]] = None, removed_params: Optional[List[str]] = None) JsString

Get the current url value. This function can also apply some filters on the existing parameters.

Parameters:
  • params – Parameters to be changed / added

  • removed_params – Parameters to be removed

property urlSearchParams: URLSearchParams

The URLSearchParams() constructor creates and returns a new URLSearchParams object.

Related Pages:

class epyk.core.js.JsLocation.URLSearchParams(query: str)
add(component: HtmlModel)
append(key: Union[str, JsDataModel], value: Any)

Append a key, value to the url parameter object.

Related Pages:

Parameters:
  • key – The url parameter

  • value – The value to be appended to the URL

delete(key)

The delete() method of the URLSearchParams interface deletes the given search parameter and all its associated values, from the list of all search parameters.

Related Pages:

Parameters:

key

get(key: str, default: Optional[Any] = None)

Get the value of a request parameter in the url.

Related Pages:

Parameters:
  • key – The url parameter

  • default – Optional. The default value

getAll(key: Union[str, JsDataModel])

Get all the values of a request parameter in the url.

Related Pages:

Parameters:

key – The url parameter

has(key: Union[str, JsDataModel])

Check if a given parameter is in the url.

Related Pages:

Parameters:

key – The url parameter

set(key: str, value: Any)

Set the value of a request parameter in the url.

Related Pages:

Parameters:
  • key – The url parameter

  • value – The value to set