views:

51

answers:

1

I've taken code from the MSDN page on Matrix Filters and modified it slightly. The functions all expect an input variable oObj which gets passed in originally from the onfilterchange:

<DIV ID="oDiv" STYLE="position:absolute;
filter:progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')"
 onfilterchange="fnSpin(this)" >

What I'm now trying to do is send arbitrary values to the setRotation function using the onclick event of a button:

<input type="button" onclick="var theDiv = document.getElementById('oDiv'); setRotation(theDiv,45)" value="Set">

Unfortunately when I click the button I get an Error: Object expected. I've obviously misunderstood what exactly this refers to in the onfilterchange - I thought it would be the HTML Element with ID oDiv. As far as I can tell filters should exist on the DIV element. I remember recently reading an excellent description of what this refers to in different situations in Javascript: The Good Parts, but I don't have access to the print version right now, and searching the Safari edition for "this" hasn't been very productive.

Things I've tried (mostly in the hope that it's an obscure IE bug):

  • Having document.getElementById('oDiv') as the first argument to setRotation
  • Using document.all instead of getElementById
  • Using different properties such as styles

Complete code is online here.

A: 

Looks to me like you have a typo:

Yours:

<input type="button" onclick="var theDiv = document.getElementById('oDiv'); setRotation(theDiv,45)" value="Set">

Websites:

<input type="button" onclick="var theDiv = document.getElementById('oDiv').style; setRotation(theDiv,45)" value="Set">

theDiv seems to refer to the style property of the actual div itself.

James
Actually I just realised I have a much worse typo than that - I have setRotation and not fnSetRotation. I'm a muppet!
robertc