Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Tuesday, September 20, 2011

iframes CAN have 100% height

I made a handy find the other day: a simple script that allows your iframe to expand to 100% of the page. This is currently impossible with CSS, but with a few lines of javascript, when you shout, "Expand!", your iframe will ask, "How high?!"
I found this script at: http://www.activewidgets.com/javascript.forum.10948.6/is-there-any-way-to.html

<script language="JavaScript">
 <!--
function resize_iframe()
{
	document.getElementById("info").innerHTML='iframe offsetTop: <b> '+document.getElementById("glu").offsetTop+"</b><br>body.offsetHeight:<b>"+document.body.offsetHeight+"</b>";//display some information on the screen
 
	var height=window.innerWidth;//Firefox
	if (document.body.clientHeight)
	{
		height=document.body.clientHeight;//IE
	}
 
	document.getElementById("glu").style.height=parseInt(height-document.getElementById("glu").offsetTop-8)+"px";//resize the iframe according to the size of the window
	//document.getElementById("glu").height=document.body.offsetHeight-document.getElementById("glu").offsetTop-26;
}
 
/*
	//Here is another way to define the function (this function reloads the page whenever the user resizes the page)
	window.onresize=
	function (e) 
	{
		location.reload();
	};
*/
 
window.onresize=resize_iframe; //instead of using this you can use: <body onresize="resize_iframe()">
//-->
</script>
I wanted my iframed page to appear to take up the entire page without displaying scrollbars of its own. The script on its own was displaying secondary scrollbars, but with a little CSS, I was able to get rid of them, leaving only one scrollbar:
<style type="text/css">
*, html, body {width: 100%; height: 100%; margin: 0; padding: 0;}
body {width: 100%; overflow: hidden;}
#glu {border: 0;}
</style>

Here is the iframe code you need:
<iframe src="YOUR_WEBPAGE_URL" frameborder="0" id="glu" onload="resize_iframe()" scrolling="auto" width="100%"></iframe>
And presto! You will have an iframe that takes up the entire window, which will resize to your browser window's size.

Demo: http://lukejohnson.ca/code/iframe-100-height.php

Thursday, March 17, 2011

Notepad++ inactive tab-color fix

If you use Notepad++ as your primary source code editor, you might share my annoyance with the background color of inactive tabs. (The default color makes the inactive tab titles very hard to read.) Even more annoying is that when a person tries to edit the colors by going to Settings / Style Configurator, the changes don't stick. Here's a handy fix:

The file you need to alter is stylers.xml, which in Windows 7 is found in: C:\\Users\[your user file]\AppData\Roaming\Notepad++\stylers.xml.

Right at the bottom of the document, the very last WidgetStyle, is the following:

WidgetStyle name="Inactive tabs" styleID="0" fgColor="555555" bgColor="f0f0f0"


I've already changed the hex colors to what I like. The fgColor controls the text color ("foreground"), and the bgColor controls the background color. Set those however you like, restart your code editor, and you should be in business!

via: Sourceforge bug support

Saturday, July 10, 2010

Programming Code and Gospel Motif

An odd combination for sure. I guess that because these are my two worlds right now --- tracing Markan motifs that climax in Jesus' death, and immersing myself in the various coding languages of the internet --- I've begun to see parallels between how the two of these things operate. Both seem to ebb and flow like well-written classical music. Just yesterday I was listening to CBC Radio 2, whose host was playing John William's score from "Return of the Jedi". I found the flow of the music so interesting. Elements of the highly recognizable themes of Darth Vader and Luke Skywalker are introduced and pulled back, repeated, reinforced, interwoven, and finally brought to a climax that makes goosebumps suddenly form. There is foreshadowing and echoing and finally full-blown revelation.

I have found that Gospel motifs work like this too, as the author introduces a theme, develops it slowly, and in the case of motifs leading to Jesus' death, brings them to such a head that they can hardly be ignored. Maybe an analogy to Visual Basic programming is a bit of a stretch (and I don't know if I understand it well enough yet to give a very helpful explanation), but here too, the first module contains a sub-routine that points forward to the next module containing the actual commands referenced in the first module. The second module's sub-routine might include a reference which propels the program to the third module, and so on. With each move forward, the program always returns to the beginning to find its instruction, forming a continuous cycle of forward and backward movement until the program fulfills its mission and the program ends.

If nothing else, thinking about similarities between code syntax and narrative development helps to keep coding interesting. (And I think I'm beginning to understand how Dr. Karen H. Jobes of Wheaton College made a transition from computer science to exegesis...)