Joomla! Web Hosting

Related

getElementById fails on IE

 

While working on a simple test page, I wanted to use getElementById to get an Image object from JavaScript.  I quickly wrote up the code and tried it.  Firefox was fine but it failed on my IE7 with "Microsoft JScript runtime error: Object doesn't support this property or method".  It took some digging to see what the problem was. 

First thing I checked was that I used both element Name and Id and that they were the same.  I *always* do that given that IE will use whichever one matches the desired string.  After reading a few blog posts about common problems but with no good ideas I went back to my code and reviewed it carefully.  It turns out that I used the same name for my element and my local JavaScript variable.  That by itself isn't a problem but what made it an issue for me was that I failed to initialize my variable with the "var" keyword. 

See the code below for the example:

<html>
<head>
<script type="text/javascript">
    function getMyImg() {
        var myFirstImg = document.getElementById("myFirstImg");
        mySecondImg = document.getElementById("mySecondImg");  <---This one will fail on IE7(probably IE5, IE6, IE8, IE9, IE...)
        if (myFirstImg.src == mySecondImg.src) {
            alert('src=' + mySecondImg.src);
        }
    }
</script>
</head>
<body>
    <a href="#" onclick="getMyImg(); return false;">Do Something</a>
    <img id="myFirstImg" src="sample.png" />
    <img id="mySecondImg" src="sample.png" />
</body>
</html>

 

Last Updated ( Friday, 13 August 2010 )
 
Discuss this item on the forums. (0 posts)


MythTV Wooden Box

With the build of my new MythTV computer that's finally using 1080P video I've been plagued by noise in the video signal.  The solution seemed pretty obvious though unappealing.  You see, I've always had my MythTV PC in the closet and used long VGA and audio runs to bring the signals to the TV & receiver.  As a result I never spent much time worrying about how much noise the machine made.  Eliminating the long VGA run should eliminate the video signal noise but introduce "real" noise into the room.

I chopped up and old PC case with my Dremel and gutted an old subwoofer.  Here's the result.  It's a fairly quiet case with only the noise of the video card fan escaping the box.

 

Image
Not much left of it

I went through a pile of Dremel cutting blades removing so much of the old case but I'm pleased with how it turned out.  It doesn't have too much strength to it without the hardware attached, but adding the motherboard, Evga 7600GT video card and Hauppage PVR 500, the whole thing feels fairly solid.

Image
Hard drive suspended with bungee cord

The hard drive is held in place nicely by the bungee cord.  Actually it's held better than I expected.  As it's not touching anything solid, it makes very little noise and is barely audfible from right outside the box.

Image
Wiring the new case

I wired in all the usual suspects that any normal case has, reusing the subwoofer's volume knob as the power button and drilled an extra hole so that I can see power and HDD access from the front panel.  A PC speaker was glued in place below the grille and a reset switch was wired into the back of the case.

Image
Test fit with old parts

I used a dead motherboard, power supply and a couple junk soundcards to test everything for proper fit.  I didn't want to risk damaging my new hardware!

Image
Test fit with old parts - Note the reset switch on the lower right.

Yup, it fits!  There's a few extra holes in the backplane as this case was chopped up by it's previous owner but I don't mind.  If I need to, I'll close up some of them with that aluminum tape normally reserved for ductwork.  So far it's fine with me.

Image
The real MythTV parts

This is the actual hardware destined to be in the box.  It's the same size as my test fit hardware so there were no surprises.   My only complaint was all the extra wires hanging out of the Corsair 450W power supply.  Cripes, they're everywhere!

Image
All closed up and in place - Note the IR(remote) receiver near the front leg

I pulled an ethernet cable to the shelf where the box would be and drilled a hole to run power to the PC, video and audio up to the receiver.

Image
Playing noise-free video. Quietly.

 The final product in action.  So far, so good.  You can hear the video card fan but that's about it.  I'm tempted to disconnect the video card's fan and see how it goes but may wait until I have a large slow moving fan to supplement the airflow.  We'll see.

 

Last Updated ( Sunday, 04 October 2009 )
 
Discuss this item on the forums. (1 posts)


MythTV with Saphire Remote

To get the Saphire remote working, all I needed wass to create a ".xmodmaprc" fine in my home folder that looks like this:

! Sapphire remote

keycode 134 = M
keycode 152 = less
keycode 180 = greater
keycode 152 = less
keycode 177 = R
keycode 179 = P
keycode 234 = Escape
keycode 223 = bar


 
Discuss this item on the forums. (1 posts)


<< Start < Prev 1 2 3 4 Next > End >>

Results 1 - 4 of 15