From 18df6815880bd922b3e5f9704f05e890248621a0 Mon Sep 17 00:00:00 2001 From: "David J. Bradshaw" Date: Wed, 29 Mar 2017 16:45:32 +0100 Subject: [PATCH] Fix tiemout warning message --- src/iframeResizer.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/iframeResizer.js b/src/iframeResizer.js index 6fbc8856b..72ccc7ce1 100644 --- a/src/iframeResizer.js +++ b/src/iframeResizer.js @@ -489,6 +489,11 @@ settings[iframeId].firstRun = false; } + function clearWarningTimeout() { + clearTimeout(settings[iframeId].msgTimeout); + settings[iframeId].warningTimeout = 0; + } + var msg = event.data, messageData = {}, @@ -499,8 +504,7 @@ } else if (isMessageForUs()){ messageData = processMsg(); iframeId = logId = messageData.id; - - clearTimeout(settings[iframeId].msgTimeout); + settings[iframeId].loaded = true; if (!isMessageFromMetaParent() && hasSettings(iframeId)){ log(iframeId,'Received: '+msg); @@ -644,17 +648,19 @@ } function warnOnNoResponse() { - function warning() { - warn(id, 'No response from iFrame. Check iFrameResizer.contentWindow.js has been loaded in iFrame'); + if (!settings[id].loaded && !errorShown) { + errorShown = true; + warn(id, 'IFrame has not responded within '+ settings[id].warningTimeout/1000 +' seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ingored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning.'); + } } - if (!!noResponseWarning) { + if (!!noResponseWarning && !!settings[id].warningTimeout) { settings[id].msgTimeout = setTimeout(warning, settings[id].warningTimeout); - } } + var errorShown = false; id = id || iframe.id;