I have firefox 21.0. For some reason, it's not resizing html elements with Javascript. When I use getElementById, it ignores the changes I try to make.
I've tried resizing and repositioning the element with this code:
widthPercentage = screen.availWidth / 800; heightPercentage = (screen.availHeight / 600); squareLeft = (124* widthPercentage); squareTop = 202; if (document.getElementById) { TEMPO = document.getElementById('SQUARE'); TEMPO.style.left = (124 * widthPercentage); I've tried with this code: squareTop = 202; squareLeft = (124 * widthPercentage); starterWidth = (495 * widthPercentage); starterHeight = (99 * heightPercentage); TEMPO = '<DIV ID="SQUARE" STYLE="position:absolute; left:squareLeft; top:squareTop; visibility:visible;">'; TEMPO += '<P>'; TEMPO += '<img name="screenTitle_box" ID="STARTER" src="ARTWORK/FRONT_SCREEN_TITLE_5.JPG" HEIGHT=starterHeight WIDTH=starterWidth>'; TEMPO += '</P>'; TEMPO += '</DIV>'; document.getElementById('SQUARE').innerHTML = TEMPO; Neither way works. But the same code works in Internet Explorer. Here's the element I'm trying to manipulate: <DIV ID="SQUARE" STYLE="position:absolute; left:333px; top:10px; visibility:visible;"> <P> <img name="screenTitle_box" ID="STARTER" src="ARTWORK/PICTURE_5.JPG" HEIGHT="150" WIDTH="900"> </P> </DIV>
I've tried resizing and repositioning the element with this code:
<pre><nowiki>widthPercentage = screen.availWidth / 800;
heightPercentage = (screen.availHeight / 600);
squareLeft = (124* widthPercentage);
squareTop = 202;
if (document.getElementById)
{
TEMPO = document.getElementById('SQUARE');
TEMPO.style.left = (124 * widthPercentage);
I've tried with this code:
squareTop = 202;
squareLeft = (124 * widthPercentage);
starterWidth = (495 * widthPercentage);
starterHeight = (99 * heightPercentage);
TEMPO = '<DIV ID="SQUARE" STYLE="position:absolute; left:squareLeft; top:squareTop; visibility:visible;">';
TEMPO += '<P>';
TEMPO += '<img name="screenTitle_box" ID="STARTER" src="ARTWORK/FRONT_SCREEN_TITLE_5.JPG" HEIGHT=starterHeight WIDTH=starterWidth>';
TEMPO += '</P>';
TEMPO += '</DIV>';
document.getElementById('SQUARE').innerHTML = TEMPO;
Neither way works. But the same code works in Internet Explorer.
Here's the element I'm trying to manipulate:
<DIV ID="SQUARE" STYLE="position:absolute; left:333px; top:10px; visibility:visible;">
<P>
<img name="screenTitle_box" ID="STARTER" src="ARTWORK/PICTURE_5.JPG" HEIGHT="150" WIDTH="900">
</P>
</DIV></nowiki></pre>
Ændret af cor-el den
Alle svar (1)
A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.
The helpers at that forum are more knowledgeable about web development issues.
You need to register at the MozillaZine forum site in order to post at that forum.