{"id":176,"date":"2006-05-22T13:55:19","date_gmt":"2006-05-22T11:55:19","guid":{"rendered":"http:\/\/www.maratz.com\/blog\/archives\/2006\/05\/22\/smart-back-to-top-link\/"},"modified":"2006-10-29T00:32:25","modified_gmt":"2006-10-28T22:32:25","slug":"smart-back-to-top-link","status":"publish","type":"post","link":"https:\/\/www.maratz.com\/blog\/archives\/2006\/05\/22\/smart-back-to-top-link\/","title":{"rendered":"Smart &#8216;back to top&#8217; link"},"content":{"rendered":"<p><em>Back to top<\/em> link\u2019s purpose is to quickly position the viewport back to a beginning of a web page. Sometimes you have a variable height of the content and this link is unnecessary if a particular page is shorter than viewport height. With this simple JavaScript, you can hide it depending on page\u2019s height. See the <a href=\"http:\/\/www.hdgrupa.hr\/\">example web site<\/a>.<\/p>\n<p><pre>\r\nvar d = document;\r\nonload = function() {\r\n    var viewport_height = (self.innerHeight) ? self.innerHeight : (document.documentElement &#38;&#38; document.documentElement.clientHeight) ? document.documentElement.clientHeight : (document.body) ? document.body.clientHeight : 0;\r\n    var page_height = d.getElementsByTagName('body')[0].offsetHeight;\r\n    var ttl = d.getElementById('to_top_link');\r\n    if (page_height < viewport_height) ttl.style.visibility = 'hidden';\r\n};\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Brings you back to the top of the page<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/176"}],"collection":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":0,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}