2011-12-08 47 views
0

是:刪除想出答案的<img>標籤的寬度和高度值

img_node.removeAttribute("width",0); 
img_node.removeAttribute("height",0); 

我有一個頁面特定的瀏覽器擴展程序,我發展,做的東西在論壇上,我經常光顧的頁面。 (http://code.google.com/p/orpcastmanagerchromeextension/wiki/About)

我有一種方法可以讓人們用特定線程組中的自定義網址替換人的頭像(這些用戶是玩遊戲的玩家通過郵寄遊戲)。

本次論壇將人的頭像IMG到寬度= 60和HEIGH = 60:

<img src="https://urlforSinbadEVsavatar" width="60" height="60" alt="SinbadEV's Avatar" border="0" title="SinbadEV's Avatar"> 

,但我希望人們能夠指定他們沒有靜態IMG大小... 假設img_node是img的節點。

我想:

img_node.width = "100%"; 
img_node.height= "100%"; 

,並得到爲0x0的圖像:

<img src="https://urlforSinbadEVsavatar" width="0" height="0" alt="SinbadEV's Avatar" border="0" title="SinbadEV's Avatar"> 

我想:

img_node.width = ""; 
img_node.height= ""; 

,並得到爲0x0的圖像:

<img src="https://urlforSinbadEVsavatar" width="0" height="0" alt="SinbadEV's Avatar" border="0" title="SinbadEV's Avatar"> 

我想:

img_node.style.width = "100%"; 
img_node.style.height= "100%"; 

,並得到1x60圖像:

<img src="https://urlforSinbadEVsavatar" width="60" height="60" alt="SinbadEV's Avatar" border="0" title="SinbadEV's Avatar" style="width: 100%; height: 100%; "> 

我想:

delete img_node.width; 
delete img_node.height; 

,並得到一個60x60的形象:

<img src="https://lh4.googleusercontent.com/-DKJY8ApOJHM/Tt_nTqBCIKI/AAAAAAAAAi0/lGF2J4nLiRo/s60/KindlyDM60x60.png" width="60" height="60" alt="SinbadEV's Avatar" border="0" title="SinbadEV's Avatar"> 

我想擺脫合作或將其設爲原始尺寸的100%。我錯過了什麼?

+0

我一直在尋找,終於發現: 'img_node.removeAttribute( 「寬度」,0);'' img_node.removeAttribute( 「高度」,0);' 這正是我一直在尋找因爲......但我還不能回答我自己的問題。 – SinbadEV

回答

0
img_node.removeAttribute("width",0); 
img_node.removeAttribute("height",0); 
相關問題