Skip to content

FIX for refresh issue #2

@kevsfastz

Description

@kevsfastz

EDIT: After some testing with below it appears some URLs will not load after adding numbers such as the date and time suggested below. Adding a ? at the end of the URL appears to be a simple workaround.

It appears this happens to URL's that do not change when refreshed. I corrected the refresh issue by adding + new Date().getTime(); after the URL in the .js file:

`Module.register("MMM-iFrameReload",{
// Default module config.
defaults: {
url: "",
height:"800px",
width:"400%",
refreshInterval: 3600,
animationSpeed: 1000
},

// Define start sequence.
start: function() {
	Log.info("Starting module: " + this.name);
	this.scheduleUpdate(this.config.refreshInterval);
},
// Override dom generator.
getDom: function() {
	var iframe = document.createElement("IFRAME");
	iframe.style = "border:0"
	iframe.width = this.config.width;
	iframe.height = this.config.height;
	iframe.src =  this.config.url + new Date().getTime();
	return iframe;
},
scheduleUpdate: function(delay) {
	var nextLoad = this.config.refreshInterval;
	if (typeof delay !== "undefined" && delay >= 0) {
		nextLoad = delay * 1000; // Convert seconds to millis
	}
	var self = this;
	setTimeout(function() {
		self.updateFrame();
	}, 30000);
	},
updateFrame: function() {
	if (this.config.url === "") {
		Log.error("Tried to refresh, iFrameReload URL not set!");
		return;
	}
	// Change url to force refresh?
	this.src = this.config.url;
	Log.info("attempting to update dom for iFrameReload");
	Log.info('/"this/" module is: ' + this);
	this.updateDom(this.config.animationSpeed);
	this.scheduleUpdate(this.config.refreshInterval);
}

});`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions