Forum Moderators: open

Message Too Old, No Replies

resize menuitem image

         

akhater

10:41 pm on Jan 7, 2006 (gmt 0)

10+ Year Member



I need to dynamically resize the image of a menuitem using javascript i've tried menuitemid.image.width with no success can anyone help?

adni18

11:26 pm on Jan 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What kind of menu are you using? A DHTML drop-down box?

akhater

11:37 pm on Jan 7, 2006 (gmt 0)

10+ Year Member



It is a drop down menu here is the javascript code

[code]

for(var i=0; i<a.length; i++)
{
var tempItem = null;
tempItem = document.createElement("menuitem");

t = a[i].split("¦¦");
tempItem.setAttribute("label", t[0]);
tempItem.setAttribute("tooltiptext", t[0]);
tempItem.setAttribute("oncommand", "dosomething");
tempItem.setAttribute("class", "menuitem-iconic");

var url=new URL(t[1]);

var purl = "http://" + url.getHost() + "/image.gif";
tempItem.setAttribute("image", purl);
hotmenu.appendChild(tempItem);
}

adni18

12:02 am on Jan 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This really doesn't help much. Could you post more code or explain more what this menu is like? Is it a standard <SELECT> tag or what?

akhater

10:40 am on Jan 9, 2006 (gmt 0)

10+ Year Member



Well let's see...
I am creating a menubutton within and xul file and the content (menuitem) of the menu are dynamic, as seen in the code they are retrieved from an array "the a array"
each field of the array contains a url and the picture of this button is specified in that url
the problem is that these picture should be resized to a 16x16 size before being displayed.

in this line of code,
tempItem.setAttribute("image", purl);
I am setting the attribute menuitem.image to the url containing the image,

if there is a way to create a javascript code to get an image and save it in the internet temp files it might also be a solution

thanks for your help

adni18

10:26 pm on Jan 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



tempItem.setAttribute("image", purl);
tempItem.setAttribute("width", "16");
tempItem.setAttribute("height", "16");

should work.

akhater

10:40 pm on Jan 9, 2006 (gmt 0)

10+ Year Member



nop it doesn't, it actually sets the width and heigh for the menuitem itself and not for the image of the menuitem

adni18

11:52 pm on Jan 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, post the code for the creation of the IMG tag, then.