{"id":15883,"date":"2017-01-25T16:15:52","date_gmt":"2017-01-25T14:15:52","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=15883"},"modified":"2017-12-19T13:23:47","modified_gmt":"2017-12-19T11:23:47","slug":"html5-history-api-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/","title":{"rendered":"HTML5 History API Example"},"content":{"rendered":"<p>Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today (with HTML5) we can perform more complex operations on the browser history stack.<br \/>\n&nbsp;<br \/>\nIn this example we are going to develop simple modules that work with the new features added to HTML5 history API.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;]<br \/>\n&nbsp;<br \/>\nFor this example we will use:<\/p>\n<ul>\n<li>A computer with a modern browser installed.<\/li>\n<li>Notepad++.<\/li>\n<\/ul>\n<h2>1. Getting Started<\/h2>\n<p>Every time a browser visits a new URL, it records or stores the URL (some browsers implementation store the URL in a local SQL database, if the browser is shut down and restarted again the user history is still available). An exception to this is when the user is surfing the web in incognito mode(the history is not stored permanently)In that case once the tab is deleted, its history is also deleted.<br \/>\n&nbsp;<br \/>\nFor example a user visits &#8220;google.com&#8221; then google.com is stored in the browser history record, as the latest record- on top of the stack. If the user then visits Microsoft.com and later webcodegeeks.com. The stack will look something like what is seen below:<\/p>\n<pre class=\"brush:bash\">http:\/\/www.webcodegeeks.com\r\nhttp:\/\/www.microsoft.com\r\nhttp:\/\/www.google.com\r\n<\/pre>\n<p>The browser pointer would be at the latest record(webcodegeeks). A go back operation will cause the pointer to move to the second URL in the list(Microsoft) and the URL is loaded either from the browser cache or the server. If the browser pointer is at webcodegeeks.com, a go forward operation is ignored because webcodegeeks.com is the first or latest record.<\/p>\n<h3>1.1 Security Restrictions<\/h3>\n<p>For good reasons their are restrictions placed on the history API, these restrictions reduce the chances of a user being scammed by a malicious website. The HTML5 history API only gives a web page access to the part of the browsing history which lies within the same domain as the web page itself. With this restriction in place, a web page cannot see or edit other websites a user has visited.<\/p>\n<p>Similarly the HTML5 history API does not allow a web page to push URLs onto the history stack(we would learn how to do this in a later section) which are outside the same domain as the domain of the web page. This restriction ensures that a web page cannot pretend to have forwarded the user to another website.<\/p>\n<h3>1.2 Old History API<\/h3>\n<p>In this section we are going to look at the methods available to the early history API(before html5). These methods can be accessed through the history object, and the latter\u00a0can be accessed through the window object. The history object has a property length, which returns the number of URLS in the history list.<br \/>\nThe methods available to the history objects are:<\/p>\n<ul>\n<li>back: When this method is called, it loads the previous URL in the history list.\n<pre class=\"brush:bash\">window.history.back();\r\n\r\n<\/pre>\n<p>It functions as if the user clicked the back button on the browser interface.<\/li>\n<li>forward:When this method is called, it loads the next URL in the history list.\n<pre class=\"brush:bash\">window.history.forward();\r\n<\/pre>\n<p>It functions as if the user clicked the forward button on the browser interface.<\/li>\n<li>go: It loads a specific URL from the history list, which is relative to the pointer current position in the history list.\n<pre class=\"brush:bash\">window.history.go(1);\/\/goes one steps forward\r\nwindow.history.go(2);\/\/goes two steps forward\r\nwindow.history.go(-1);\/\/goes one step backward\r\n\r\nwindow.history.go(-2);\/\/goes two step backward\r\n<\/pre>\n<\/li>\n<\/ul>\n<p>Since the\u00a0window object is the default object you can leave it out. A user cannot move forward in history unless the user has first moved back in history.<br \/>\nLets look at a complete example below:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.html<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:visible;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n#pick{\r\nmargin:10px;\r\n}\r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt; \r\nHtml5 History API Example\r\n&lt;\/title&gt;\r\n\r\n\t&lt;\/head&gt;\r\n\t&lt;body onload=init()&gt;\r\n&lt;script&gt;\r\nfunction init(){\r\nvar b=document.getElementById(\"back\")\r\n\/\/get the back button \r\nb.addEventListener(\"click\",goback,false);\/\/register an onclick event listener\r\nvar f=document.getElementById(\"forward\")\r\n\/\/get the forward button \r\nf.addEventListener(\"click\",goforward,false);\/\/register an onclick event listener\r\nvar b=document.getElementById(\"go\")\r\n\/\/get the go button \r\nb.addEventListener(\"click\",gos,false);\/\/register an onclick event listener\r\n}\r\nfunction goback(){\r\nwindow.history.back();\/\/call the history method go back\r\nconsole.log(\"going back\")\/\/print out message\r\n\r\n}\r\nfunction goforward(){\r\nwindow.history.forward();\/\/call the history method go forward\r\nconsole.log(\"going forward\")\/\/print out message\r\n\r\n}\r\nfunction gos(){\r\nvar d=document.getElementById(\"tex\")\r\nvar d1=d.value;\r\nif(d1==\"\")\r\nconsole.error(\"Wrong Value Specified\");\/\/no valid input was found, print out error message\r\nelse\r\nwindow.history.go(d1);\r\nconsole.log(\"going to a specified position\");\/\/ print out message\r\n\r\n}\r\n&lt;\/script&gt;\r\n&lt;p&gt;\r\n&lt;p&gt;\r\n&lt;input type = button id = back value=back&gt;\r\n&lt;\/p&gt;\r\n&lt;p&gt;\r\n&lt;input type = button id = forward value=forward&gt;\r\n&lt;\/p&gt;\r\n&lt;p&gt;\r\n&lt;label&gt;Enter a valid step number&lt;\/label&gt;\r\n&lt;input type = text id = tex &gt;\r\n&lt;input type = button id = go value=go&gt;\r\n&lt;\/p&gt;\r\n&lt;\/p&gt;\r\n\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<p>We add three buttons and a textbox to the user interface. Click the button labelled back to go back, click the button labelled forward to go forward, enter a valid number in the textbox and click go to move to a specific URL.<br \/>\n&nbsp;<br \/>\n<b>Note<\/b> The script doesn&#8217;t check for illegal values like letters. So make sure you enter a valid number e.g 1, 2, -1, -2. This example works best when your browser\/tab actually has a history length greater than 0.<br \/>\n&nbsp;<br \/>\n<b>Note<\/b>: Inline JavaScript should be avoided because it makes the markup bigger and less readable. The content, structure and behavior are not well-separated, thus making a bug harder to find. Furthermore, usage of event attributes almost always causes scripts to expose global functions on the\u00a0Window\u00a0object, thus polluting the global namespace.<\/p>\n<h3>1.3 New API<\/h3>\n<p>The new API were added in HTML5. The methods we can work with are:<\/p>\n<ul>\n<li>pushState(): This method pushes a state to the history stack or list. A simple example below\n<pre class=\"brush:html\">var stateobj = {}; \r\nvar title = \"\"; \r\nvar url = \"index.html\";\r\nhistory.pushState(stateobj, title, url);\r\n\r\n<\/pre>\n<p>This will cause the URL bar to display the full URL, but the browser won&#8217;t load\u00a0the URL or even check if\u00a0it\u00a0exists. Suppose the user now navigates to\u00a0<a href=\"http:\/\/google.com\">http:\/\/google.com<\/a>, then clicks back. At this point, the URL bar will display\u00a0http:\/\/someexample\/index.html. The push state function takes three parameters:<br \/>\nstate object: is simply a JavaScript object. Whenever the user navigates to the new state, a\u00a0popstate\u00a0event is fired, and the\u00a0state\u00a0property of the event contains a copy of the history entry&#8217;s state object.<\/p>\n<p>title:A string value. It is currently ignored my some browsers.<\/p>\n<p>URL: The URL to be added to the history stack. It doesn&#8217;t need to be absolute, it can be a relative URL. The new URL must be of the same origin as the current URL else an exception is thrown. It is an optional parameter, if it is not provided, the current URL is assumed.<\/li>\n<li>replaceState(): The\u00a0replaceState()\u00a0function replaces the history element in the history stack that is being pointed to right now. This may not be the top element if the user has moved back in history using the &#8220;back&#8221; button.<br \/>\nThis will also change the URL in the browser&#8217;s address field though it will not make the browser load the URL. The page that replaced the URL remains loaded in the browser.<\/p>\n<pre class=\"brush:html\">var stateobj = {}; \r\nvar title = \"\"; \r\nvar url = \"index.html\";\r\nhistory.replaceState(stateobj, title, url);\r\n\r\n<\/pre>\n<\/li>\n<\/ul>\n<h3>1.4 pop state event<\/h3>\n<p>A pop state event is fired every time the history entry changes.<code> pushState()<\/code> and<code>replaceState()<\/code> both fire this event and their state object is contained as part of the event property.<\/p>\n<pre class=\"brush:html\">window.onpopstate = function(event) { console.log(\"history has changed to: \" + document.location.href);\/\/we create a log message.\r\n\r\n }<\/pre>\n<p>It is possible to read the state of the current history entry without waiting for a popstate\u00a0event.<\/p>\n<pre class=\"brush:bash\">var newstate = history.state;\r\n\r\n<\/pre>\n<h2>2. Summary<\/h2>\n<p>In this example we learnt about the history object and its methods, we also studied about its restrictions.<\/p>\n<h2>3. Download the Source Code<\/h2>\n<div class=\"download\">\n<p><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here:\u00a0<strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/01\/html5historyapiexample.zip\">html5historyapiexample<\/a><\/strong><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today (with HTML5) we can perform more complex operations on the browser history stack. &nbsp; In this example we are going to develop simple modules that work with the new features added to &hellip;<\/p>\n","protected":false},"author":164,"featured_media":914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[429],"class_list":["post-15883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html5","tag-history-api"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML5 History API Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML5 History API Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-25T14:15:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-19T11:23:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"HTML5 History API Example\",\"datePublished\":\"2017-01-25T14:15:52+00:00\",\"dateModified\":\"2017-12-19T11:23:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/\"},\"wordCount\":1075,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"keywords\":[\"history api\"],\"articleSection\":[\"HTML5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/\",\"name\":\"HTML5 History API Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"datePublished\":\"2017-01-25T14:15:52+00:00\",\"dateModified\":\"2017-12-19T11:23:47+00:00\",\"description\":\"Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML5\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/html5\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML5 History API Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML5 History API Example - Web Code Geeks - 2026","description":"Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/","og_locale":"en_US","og_type":"article","og_title":"HTML5 History API Example - Web Code Geeks - 2026","og_description":"Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today","og_url":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-01-25T14:15:52+00:00","article_modified_time":"2017-12-19T11:23:47+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"HTML5 History API Example","datePublished":"2017-01-25T14:15:52+00:00","dateModified":"2017-12-19T11:23:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/"},"wordCount":1075,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","keywords":["history api"],"articleSection":["HTML5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/","url":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/","name":"HTML5 History API Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","datePublished":"2017-01-25T14:15:52+00:00","dateModified":"2017-12-19T11:23:47+00:00","description":"Pre HTML5 we could only perform few basic operations on the browser history stack, simple operations like re-visiting a previously visited URL. Today","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-history-api-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"HTML5","item":"https:\/\/www.webcodegeeks.com\/category\/html5\/"},{"@type":"ListItem","position":3,"name":"HTML5 History API Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=15883"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15883\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=15883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=15883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=15883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}