Dynamically Resizing an IFrame to Fill The Browser

If you ever work with an IFrame, you will notice that you can’t set height=100%.

But, many times you might want to have an IFrame act as if that property had the desired effect.  i.e. If you make your browser window taller, you want the heigh of your IFrame to grow as well.

You can acheive this using the following script:

       function resize_iframe() {
            var myWidth = 0, myHeight = 0;
            if( typeof( window.innerWidth ) == 'number' ) {
                //Non-IE
                myWidth = window.innerWidth;
                myHeight = window.innerHeight;
            } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
                //IE 6+ in 'standards compliant mode'
                myWidth = document.documentElement.clientWidth;
                myHeight = document.documentElement.clientHeight;
            } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                //IE 4 compatible
                myWidth = document.body.clientWidth;
                myHeight = document.body.clientHeight;
            }

            var iNewHeight;
            iNewHeight = parseInt(myHeight)-40;
            document.getElementById("WgipIFrame").style.height = iNewHeight;
        }

        //-- see if there is already something on the onresize
        var tempOnresize = window.onresize;
        //-- create our event handler
        window.onresize = function(){
            //-- if tempFunc is a function, try to call it
            if (typeof (tempOnresize) == "function"){
                try{
                    tempOnresize();
                } catch(e){} //--- if it errors, don't let it crash our script
            }
            resize_iframe();
        }

Then you can set the IFrame’s onload=”resize_iframe();” like this:

<iframe src="x.htm" style="width:100%;"
  id="WgipIFrame" name="WgipIFrame"
  onload="resize_iframe();"></iframe>

 

Donnie Darko

I just went to download the song “Mad World”, which is featured in a really cool commerical for Gears of War.

When I went to download it, I found that the song, along with a remix, were part of the Donnie Darko sound track.

Donnie Darko was one of those movies that almost no one saw, and somehow I ended up renting it, and it was fantastic.

I guess I am really attracted to movies like Darko.  The Butterfly Effect was another movie that the critics, and most people I guess, didn’t like, but I also throught it was really cool.

Both feature people who are experiencing things that shouldn’t be happening…  I guess you could throw the Matrix movies in with this group too, but they were really popular.

Another one like these is The Forgotten, where a Mother wakes up and finds that no one can remember that she had a child at one point.  She questions her own sanity, as does Darko and so does the Aston Kutcher character in Butterfly.

The Mothman Prophecies is also a pretty similar film, although, not quite as good. 

But all of these movies kept me very interested, and really left a creepy feeling after they were over.

 

Finding Browser Window Height

Here is a nice script, part of a larger section on getting window size/positions and scroll data out of various browsers.  This page really has a lot of good information.

function alertSize() {
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    window.alert( 'Width = ' + myWidth );
    window.alert( 'Height = ' + myHeight );
}

Resetting Domain Admin Passwords

I have been researching ways to reset a domain admin password for a client who forgot what they typed in when they set the password.

Most password crackers work only on local accounts, not for anything on a domain.  It seems like the way to go about this is to reset the local admin account, then login using Directory Service Recovery Mode to reset the domain admin account.

Here are some of the articles I have been reading:

http://www.jms1.net/nt-unlock.shtml  <– this idiot won’t let you view his pages if you are running IE, so use firebox, but again, that’s just stupid

http://www.nobodix.org/seb/win2003_adminpass.html

http://home.eunet.no/~pnordahl/ntpasswd/

http://www.loginrecovery.com/about.html

http://www.petri.co.il/reset_domain_admin_password_in_windows_server_2003_ad.htm

 

University of Chicago Academic Calendar

I find myself frequently trying to find the dates on this calendar, and I can never find any links to this site.

http://academic-calendar.uchicago.edu/future/index.html

It has all the dates of academic interest (days off, starting and ending days of each quater).

This quater I am planning on taking Bioinformatics.

I saw a presentation on Bioinformatics at Fermi Lab.  They have searching programs to look at, I believe, the genome sequence, to find similar patterns.  Pretty interesting.

Hopefully the course will be good too!

Using window.onload without overwriting existing onload event handlers

When you are creating reusable javascript files, there are times when you want to tap into the window.onload event, which is fired when the window has finished loading the content.

The problem here, is that you can’t have multiple event handlers for the same event.

So if you have a page that uses 2 scripts which both use the window.onload event, then which ever is loaded last will win, and the other script will never catch the event.

Well one way you can deal with this problem is to write your window.onload (or other events for that matter) using this type of a pattern:

    //-- see if there is already something on the onload
    var tempFunc = window.onload;
    //-- create our event handler
    window.onload = function(){
        //-- if tempFunc is a function, try to call it
        if (typeof (tempFunc) == "function"){
            try{
                tempFunc();
            } catch(e){} //--- if it errors, don't let it crash our script
        }
     //-- Call your onload function here
    }

This way, you can have several function that all utilize the onload event, and none of them have to know about each other.

 

Getting Real

Here is the online version (free) of 37Signals.com book on development: Getting Real.

I think they have basically an agile approach to not only software development but business as well.

Like almost all development methodologies, I think some of their ideas are pretty valid, unless they aren’t.

For example, some of the things I hear a lot from the sort of XP / Agile development styles are things like:

 “Get your app out as soon as possible, even if it isn’t fully debugged or fully complete.  Let your users tell you what features need to be added, rather than spending the time guessing what they want”

and

“2 rules of performance optimization. 1) Don’t.  2) Not yet!”

 

1) If you get your app out, and you start spending you time getting people to use it, and it sucks, then you have actively made people who had no opinion of your product now have a negative opinion.  If you fix the bugs and add features later, they will just remember that they tried it, and it sucked.

2) You can always add performance optimization later, except what about when need to rewrite 2 months of work because you were too lazy to spend an extra 4 hours during the design phase to build in some ability to scale?