From 5b76c5eddfac79727ee39be91aed9ad8b57aa887 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Mon, 4 Jan 2016 17:26:15 +0530 Subject: [PATCH] Fix #11812 Uncaught TypeError: Cannot read property 'parentNode' of null Signed-off-by: Atul Pratap Singh --- js/cross_framing_protection.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/js/cross_framing_protection.js b/js/cross_framing_protection.js index 148c9a9ba9..49013f65c9 100644 --- a/js/cross_framing_protection.js +++ b/js/cross_framing_protection.js @@ -2,9 +2,15 @@ /** * Conditionally included if framing is not allowed */ -if (self == top) { - var style_element = document.getElementById("cfs-style"); - style_element.parentNode.removeChild(style_element); -} else { - top.location = self.location; +window.onload = function () { + if (self == top) { + var style_element = document.getElementById("cfs-style"); + // check if style_element has already been removed + // to avoid frequently reported js error + if (typeof(style_element) != 'undefined' && style_element != null) { + style_element.parentNode.removeChild(style_element); + } + } else { + top.location = self.location; + } }