Options
All
  • Public
  • Public/Protected
  • All
Menu

An abstraction of the browser entity an all its related operations and properties Browser entity is normally available only on client side or front end view applications, but some of its features can also make sense on a server side app. So depending on the implementation language, this class may or may not have some of its methods implemented.

Hierarchy

  • BrowserManager

Index

Methods

deleteCookie

  • deleteCookie(key: string, path?: string): boolean
  • Deletes the specified cookie from browser. Note that the cookie will only be deleted if belongs to the same path as specified.

    Parameters

    • key: string

      The name of the cookie we want to delete

    • Default value path: string = "/"

      Define the path where the cookie is set. By default it is the whole domain: '/'. If the cookie is not set on this path, we must pass the right one or the delete will fail.

    Returns boolean

    True if cookie was deleted or false if cookie could not be deleted or was not found.

disableScroll

  • disableScroll(): void
  • Totally disables the current page scrolling. Useful when creating popups or elements that have an internal scroll, and we don't want it to interfere with the main document scroll.

    Can be enabled again with enableScroll.

    Returns void

    void

enableScroll

  • enableScroll(): void
  • Restores main document scrolling if has been disabled with HtmlUtils.disableScroll

    Returns void

    void

getCookie

  • getCookie(key: string): string
  • Get the value for an existing cookie.

    Adapted from the jquery.cookie plugin by Klaus Hartl: https://github.com/carhartl/jquery-cookie

    Parameters

    • key: string

      the name of the cookie we want to get

    Returns string

    Cookie value or null if cookie does not exist

getCurrentUrl

  • getCurrentUrl(): string
  • Get the current page full url, including 'https://', domain and any uri get parameters

    Returns string

    A well formed url

getDocumentHeight

  • getDocumentHeight(): number
  • Obtain the current html document height in pixels

    Returns number

    Numeric value representing the document height in pixels

getDocumentWidth

  • getDocumentWidth(): number
  • Obtain the current html document width in pixels

    Returns number

    Numeric value representing the document width in pixels

getPreferredLanguage

  • getPreferredLanguage(): any
  • Tries to detect the language that is set as preferred by the user on the current browser. NOTE: Getting browser language is not accurate. It is always better to use server side language detection

    Returns any

    A two digits string containing the detected browser language. For example 'es', 'en', ...

getScrollPosition

  • getScrollPosition(): number[]
  • Gives the current position for the browser scroll

    Returns number[]

    Array with the current x,y position based on the top left corner of the current document

getWindowHeight

  • getWindowHeight(): number

getWindowWidth

  • getWindowWidth(): number

goToUrl

  • goToUrl(url: string, newWindow?: boolean, postData?: Object | null): void
  • Opens the specified url on the browser's current tab or in a new one.

    Parameters

    • url: string

      The url that will be loaded

    • Default value newWindow: boolean = false

      Setting it to true will open the url on a new browser tab. False by default

    • Default value postData: Object | null = null

      If we want to send POST data to the url, we can set this parameter to an object where each property will be translated to a POST variable name, and each property value to the POST variable value

    Returns void

    void

isCookie

  • isCookie(key: string): boolean
  • Check if the specified cookie exists

    Parameters

    • key: string

      the name for the cookie we want to find

    Returns boolean

    True if cookie with specified name exists, false otherwise

isDocumentLoaded

  • isDocumentLoaded(): boolean
  • Tells if the current html document is fully loaded or not.

    Returns boolean

    True if the current html document is fully loaded (including all frames, objects and images) or false otherwise.

reload

  • reload(): void
  • Reloads the current url. This will make the browser load all the current html document again and all page state will be lost.

    Returns void

    void

scrollTo

  • scrollTo(destination: HTMLElement | [number, number], duration?: number, callback?: Function | null): void
  • Moves the browser scroll to the specified X,Y axis position or DOM element.

    example

    browserManager.scrollTo(document.querySelector('#myId'), 800);

    example

    browserManager.scrollTo([100,200], 1000);

    see

    https://pawelgrzybek.com/page-scroll-in-vanilla-javascript/

    Parameters

    • destination: HTMLElement | [number, number]

      The location where the scroll must be moved to. It can be an HTML element instance or an array of two numbers with the [x,y] destination coordinates

    • Default value duration: number = 600

      The animation duration in miliseconds. Set it to 0 to perform a direct scroll change.

    • Default value callback: Function | null = null

      A method that will be executed right after the scroll finishes

    Returns void

    void

setCookie

  • setCookie(key: string, value: string, expires?: any, path?: string, domain?: string, secure?: boolean): boolean
  • Set the value for a cookie or create it if not exist

    Adapted from the jquery.cookie plugin by Klaus Hartl: https://github.com/carhartl/jquery-cookie

    Parameters

    • key: string

      the name for the cookie we want to create

    • value: string

      the value we want to set to the new cookie.

    • Default value expires: any = ""

      The lifetime of the cookie. Value can be a Number which will be interpreted as days from time of creation or a Date object. If omitted or '' string, the cookie becomes a session cookie.

    • Default value path: string = "/"

      Define the path where the cookie is valid. By default it is the whole domain: '/'. A specific path can be passed (/ca/Home/) or a '' string to set it as the current site http path.

    • Default value domain: string = ""

      Define the domain where the cookie is valid. Default: domain of page where the cookie was created.

    • Default value secure: boolean = false

      If true, the cookie transmission requires a secure protocol (https). Default: false.

    Returns boolean

    True if cookie was created, false otherwise. An exception may be thrown if invalid parameters are specified

Generated using TypeDoc