搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

removeAttribute doesn't seem to do so.

  • 1 回覆
  • 1 有這個問題
  • 10 次檢視
  • 最近回覆由 briansmither

more options

I am trying to do this in an <img id='player' src=' ' alt='alt' title='title' border='0' onerror="document.getElementById('player').removeAttribute('src');document.getElementById('player').removeAttribute('alt');document.getElementById('player').removeAttribute('title');" /> tag.

When I view Generated Source in FF2 (Web Developer 1.1.9), the attributes are not shown in the source listing, and the title attribute still displays in the page.

When I view Generated Source in FF4, the attributes are present in the source listing, and the title attribute still displays on the page.

I am trying to do this in an &lt;img id='player' src=' ' alt='alt' title='title' border='0' onerror="document.getElementById('player').removeAttribute('src');document.getElementById('player').removeAttribute('alt');document.getElementById('player').removeAttribute('title');" /&gt; tag. When I view Generated Source in FF2 (Web Developer 1.1.9), the attributes are not shown in the source listing, and the title attribute still displays in the page. When I view Generated Source in FF4, the attributes are present in the source listing, and the title attribute still displays on the page.

由 briansmither 於 修改

所有回覆 (1)

more options

(In my original post above, I had to use a space as the value for the src attribute, otherwise this editor would not show it. But my actual code is a zero-length string.)

I believe that FF4 does not consider a zero-length string as a triggerable error. I change the src attribute's value to '#' and all is working as desired.

由 briansmither 於 修改