P
Pawel_Iks
I write following script which change font-size for the text in
element with id="p1" and display current font-size in element with
id="p2". I want to know why the following code is processed corectly
by Firefox and there are some error in IE 7?
<html>
<head>
<title>JavaScript example - getElementById</title>
<script type="text/javascript">
var fontSizeTab=new Array();
fontSizeTab=["5pt","6pt","7pt","8pt","9pt","10pt","11pt","12pt","13pt","14pt","15pt","16pt","17pt","18pt","19pt","20pt","22pt","23pt","24pt","25pt"];
var indx=5;
function increaseSize()
{
p2=document.getElementById('p2');
if (indx<fontSizeTab.length-1)
{
indx++;
p2.innerHTML="<b>rozmiar:</b> "+fontSizeTab[indx];
}
else
p2.innerHTML+=" <b>górna granica</b>";
obj=document.getElementById("p1");
obj.style.fontSize=fontSizeTab[indx];
}
function decreaseSize()
{
p2=document.getElementById("p2");
if (indx>0)
{
indx--;
p2.innerHTML="<b>rozmiar:</b> "+fontSizeTab[indx];
}
else
p2.innerHTML+=" <b>dolna granica</b>";
obj=document.getElementById("p1");
obj.style.fontSize=fontSizeTab[indx];
}
</script>
</head>
<body>
<form name="form1">
<input type="button" value="+" onClick="increaseSize();"/>
<input type="button" value="-" onClick="decreaseSize();"/>
</form>
<p id="p1" name="p1" style="font-size:10pt;">
some text here
</p>
<p id="p2" name="p2">
</p>
</body>
</html>
element with id="p1" and display current font-size in element with
id="p2". I want to know why the following code is processed corectly
by Firefox and there are some error in IE 7?
<html>
<head>
<title>JavaScript example - getElementById</title>
<script type="text/javascript">
var fontSizeTab=new Array();
fontSizeTab=["5pt","6pt","7pt","8pt","9pt","10pt","11pt","12pt","13pt","14pt","15pt","16pt","17pt","18pt","19pt","20pt","22pt","23pt","24pt","25pt"];
var indx=5;
function increaseSize()
{
p2=document.getElementById('p2');
if (indx<fontSizeTab.length-1)
{
indx++;
p2.innerHTML="<b>rozmiar:</b> "+fontSizeTab[indx];
}
else
p2.innerHTML+=" <b>górna granica</b>";
obj=document.getElementById("p1");
obj.style.fontSize=fontSizeTab[indx];
}
function decreaseSize()
{
p2=document.getElementById("p2");
if (indx>0)
{
indx--;
p2.innerHTML="<b>rozmiar:</b> "+fontSizeTab[indx];
}
else
p2.innerHTML+=" <b>dolna granica</b>";
obj=document.getElementById("p1");
obj.style.fontSize=fontSizeTab[indx];
}
</script>
</head>
<body>
<form name="form1">
<input type="button" value="+" onClick="increaseSize();"/>
<input type="button" value="-" onClick="decreaseSize();"/>
</form>
<p id="p1" name="p1" style="font-size:10pt;">
some text here
</p>
<p id="p2" name="p2">
</p>
</body>
</html>