From 5b321638570b2d5c9245fa3c25369b4079c0ffa6 Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 29 Mar 2012 17:17:06 +0100 Subject: [PATCH] Fix patch js hack for Chrome Chrome doesn't handle window.onload in the same way as other browsers, this compensates (and cleans up the JS a little) Change-Id: If629155a6f305e5079f70db6d4045896fb43b483 --- modules/gerrit/files/GerritSiteHeader.html | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/gerrit/files/GerritSiteHeader.html b/modules/gerrit/files/GerritSiteHeader.html index d243607e35..26032c543f 100644 --- a/modules/gerrit/files/GerritSiteHeader.html +++ b/modules/gerrit/files/GerritSiteHeader.html @@ -5,14 +5,11 @@ var hash = window.location.hash; return hash.substring(1); // remove # } - window.onload = function() { - var hash_arr= getHash().split(","); - if (hash_arr[0] == 'patch') { - var elem = document.getElementById("gerrit_body"); - elem.className = elem.className + ' patch'; - } - }; - window.onhashchange = function() { + + window.onload = setTimeout(add_patch_tag, 1000) + window.onhashchange = add_patch_tag + + function add_patch_tag() { var hash_arr= getHash().split(","); var elem = document.getElementById("gerrit_body"); if (hash_arr[0] == 'patch') { @@ -20,7 +17,7 @@ } else { elem.className = elem.className.replace(' patch', ''); } - }; + }