找出答案是:
img_node.removeAttribute("width",0);
img_node.removeAttribute("height",0);
我正在开发一个特定于页面的Chrome扩展程序,它会在我经常访问的论坛上发布内容。 (http://code.google.com/p/orpcastmanagerchromeextension/wiki/About)
我有办法让人们用特定线程组中的自定义网址替换人物的头像(这些用户是游戏中的玩家)。
论坛将人们的头像img设置为width = 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 :(得分:0)
img_node.removeAttribute("width",0);
img_node.removeAttribute("height",0);