diff --git a/JavaScript/Advance/Web API/web-history API/images/js-logo.png b/JavaScript/Advance/Web API/web-history API/images/js-logo.png new file mode 100644 index 0000000..4637ac9 Binary files /dev/null and b/JavaScript/Advance/Web API/web-history API/images/js-logo.png differ diff --git a/JavaScript/Advance/Web API/web-history API/index.html b/JavaScript/Advance/Web API/web-history API/index.html new file mode 100644 index 0000000..0689dd5 --- /dev/null +++ b/JavaScript/Advance/Web API/web-history API/index.html @@ -0,0 +1,27 @@ + + + + + + + + web-history API + + + +

Web History API

+ +

+ +

History back()

+ + +

History go()

+ + +

History forward()

+ + + + + \ No newline at end of file diff --git a/JavaScript/Advance/Web API/web-history API/script.js b/JavaScript/Advance/Web API/web-history API/script.js new file mode 100644 index 0000000..91d37b3 --- /dev/null +++ b/JavaScript/Advance/Web API/web-history API/script.js @@ -0,0 +1,42 @@ +// In this lesson we will learn about Web History API + +let textOne = document.getElementById('textOne'); +let viewDoc = document.getElementById('viewDoc'); + +viewDoc.addEventListener("click", () => { + let x = true; + if (x == true) { + textOne.innerHTML = ` +

The Web History API provides easy methods to access the windows.history object.

+

The window.history object contains the URLs (Web Sites) visited by the user.

+

There are three main types of History API

+
  • back()
  • +
  • go(-2)
  • +
  • forward()
  • +

    Check the Examples Below with the .js files for better Understanding

    +

    This will work when we are having more than one web pages in a website

    + ` + x = false; + } else { + textOne.innerHTML.style.display = "none"; + x = true; + } +}) + +// History back() + +function DisplayTwo() { + window.history.back(); +} + +// History go() + +function DisplayThree() { + window.history.go(-2); +} + +// History forward() + +function DisplayFour() { + window.history.forward(); +} \ No newline at end of file