The history object stores all the URLs of the HTML pages through which the user has passed during the current browser session. It is a copy of the information stored in the Go option from the Navigator menu bar.

 

By default, access to the object is given in the following format:

history.property

history.method

 

As access methods and properties are done in the same way, one should know each.

Properties:

lenght – Reports the number of page views.

Eg history.lenght

 

Methods:

back – Returns to the previous page, according to the page regarding the history object. Same as clicking your browser’s back button.

Eg.: history.back ()

 

Forward – Moves to the next page, according to the page regarding the history object. Same as clicking the browser forward button.

Eg.: history.forward ()

 

Go – Allows any URL is present in the list of visited pages of the history object, is loaded.

Eg.: history.go (parameter)

 

There are two possibilities for “parameter” in this case:

  1. Parameter is a number: to set a number, this must be an integer. If it is positive, the target page is “parameter” to the front pages. Whereas if it is negative, the target page is “parameter” pages back;
  2. Parameter is a string: In this case, the target is the URL that most closely resembles the string value defined by “parameter”.

 

Finally, the window object is at the top of the hierarchical scheme in JavaScript. Your access is in the same format of the history object and again there is the need to know the methods and properties available in it.

 

Properties:

defaultStatus – Determines the default contents of the browser’s status bar when nothing important is happening.

Eg widow.defaultStatus = ‘Anything’

 

frames – Vector that stores references to the frames of the current window.

Eg parent.frames.lenght // get the number of frames of the main window, assuming that we are in a frame.

 

parent – Refers to the parent of the current frame window.

 

self – Refers to the current window.

Eg.: self.defaultStatus = ‘Anything’

 

status – Sets a message that will appear in the browser footer, replacing for example, the URL of a link when we’re with the mouse over the link.

Eg.: window.status = “any text”

 

top – Refers to the highest level window of the hierarchical scheme of JavaScript.

Eg.:  top.close () // close the main browser window

 

window – Refers to the current window. It operates analogously to self.

Eg.:  window.status = ‘Anything’

 

Methods:

alert – Displays an alert box, followed by a beep and the OK button.

Eg.: alert (‘This is an alert window!’)

 

close – Ends the current browser session.

Eg.:  top.close ()

 

confirm – shows a dialog box, followed by a beep and buttons ‘OK’ and ‘Cancel’. It returns a true value if the user chooses OK.

Eg.: return = confirm (‘Do you want to proceed?’)

 

open – Open a new browser session, as if the user pressed N +

Eg.: window.open (“URL”, “name” [“character”])

 

  • URL: address initially selected when opening a new window;
  • Name: name of the new window, defined by the programmer;
  • Features – number of configuration options for the new window. If specified, must be on the same string, separated by commas and no spaces contain:

 

the toolbar = 0 or 1

The location = 0 or 1

the directories = 0 or 1

status = 0 or 1 menubar = 0 or 1

The scrollbars = 0 or 1

the resizable = 0 or 1

the width = positive integer value

the height = positive integer value

 

prompt – Sets up a data entry box, in a simplified manner compared with the text object. Eg prompt (label [, value])

 

  • label: text that appears next to the box;
  • Value: the initial contents of the box;
  • setTimeout – Makes an expression to be evaluated after a certain time (in milliseconds).

 

ID – identifier used for canceling setTimeOut.

 

clearTimeout – Cancel setTimeOut.

Eg.: clearTimeout (ID)

 

The window object also has two events that can be used in the handling of the window data and including:

 

  • onLoad: It occurs as soon as the HTML page finishes loading.
  • onUnload: occurs as soon as the user leaves the current page.

Visit our blog and check out more content!

By ,

February 29, 2016

a

You might also like…

AI-Driven Software Development: The Role of ChatGPT

In the rapidly evolving world of technology, artificial intelligence (AI) is playing an increasingl...

Low-Code: The Key to Accessible Digital Transformation

Digital transformation is imperative for companies wishing to remain competitive in the current era...

Low-code: Simplifying Development Without Sacrificing Quality

In today's agile and competitive world, productivity is crucial for the success of any business. Th...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.