2009-09-03 72 views
0

我採取了MSDN page on Matrix Filters的代碼並對其稍作修改。這些功能都期望可變oObj其輸入端獲取來自onfilterchange通過最初:這指的是onfilterchange屬性是什麼?

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

什麼我現在想要做的是使用onclick事件一鍵發送任意值到setRotation功能:

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

不幸的是,當我點擊按鈕,我得到一個錯誤:對象的預期。我明顯誤解了thisonfilterchange中引用的內容 - 我認爲這將是ID爲oDiv的HTML元素。據我可以告訴filters should exist on the DIV element。我記得最近讀了thisJavascript: The Good Parts的不同情況下提到的一個很好的描述,但我現在無法訪問打印版本,並且在Safari版本中搜索「this」的效率並不高。

事情我已經嘗試過(大多是希望它是一個模糊的IE漏洞):

  • document.getElementById('oDiv')作爲第一個參數setRotation
  • 使用的document.all代替getElementById
  • 使用不同的屬性如styles

Complete code is online here

回答

0

在我看來就像你有一個錯字:

此致:

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

網站:

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

theDiv似乎是指實際的DIV本身的風格財產。

+0

其實我只是意識到我有一個更糟糕的錯字比 - 我有setRotation而不是fnSetRotation。我是個笨蛋! – robertc