Jim Coyne
Kilo Patron
Part of the "Tips 'N Tricks" series.

 

I ran into this article on the weekend: Learning Popup Height Adjuster for NowLearning: Enhance Your Learning Experience! and thought "why didn't I think of that?".  The height of the popup window on my screen has been driving me crazy, only using a bit more than half of the height of my monitor.  Why can't it be taller?

 

So, after reading that post I mentioned above, I didn't want to install something else just to resize the window, so I just created a simple bookmarklet to do the trick.  All you have to do is create a new bookmark in your favourite browser, give it a useful name and paste the following code into the URL or Location field:

 

 

javascript:(function(){
	try {
		var iframe = document.getElementsByClassName("scorm-iframe")[0];
		iframe.style.height = "95em";
	} catch(err) {}
})();

 

 

NOTE: When you paste the code into the bookmark/favourite, change ":" in the first line of code above with the actual colon character ":".

 

You will end up with a bookmark you can click to quickly resize the window now:

 

JimCoyne_0-1721543629153.png

 

 

JimCoyne_4-1708030511131.png

 

Simple and effective.  You'll probably have to play with the "95em" to get the right height for your monitor.  I could have added some smarts to figure out to optimum height, but sometimes you just have to get it done and move onto the next problem.

 

Kudos to @dogieglo and thanks for the inspiration.

 

EDIT: Here's a slightly more complicated version with some checking and sets the iframe height to a certain percentage of the window height as was suggested:

javascript:(function(){
	const desiredHeightPercent = 0.9;
	const learningDomain = "learning.servicenow.com";
	try {
		/* make sure it is a Now Learning window first */
		const url = decodeURIComponent(window.location.toString());
		if (url.indexOf(learningDomain) != -1) {
			console.log("Looking for scorm-iframe...");
			var element = document.getElementsByClassName("scorm-iframe")[0];
			element.style.height = document.getElementsByTagName('body')[0].clientHeight * desiredHeightPercent + 'px';
		} else {
			console.warn("Does not seem to be a Now Learning window: " + url);
		}
	} catch(err) {
		console.warn(err);
	}
})();

 

13 Comments