I need this code to work for all the IE, Netscape, Opera, and Mozilla
versions. To go about doing this, it is a definite task. I have it
working in IE(all versions) but it will not increment or decrement the
font size in any other browsers. Any suggestions?
<html>
<head>
</head>
<body>
<h1>Hello there</h1>
<h2>Test</h2>
anything.
<input type="submit" onclick="resize BodyText(2, 'n')" >
<input type="submit" onclick="resize BodyText(-2, 'n')" >
<button type="submit" onclick= "resizeBodyText (0, 'y')" >
<script type="text/javascript">
//-------------------------------------------------
var current = parseInt(getCoo kie("fontFactor "))
if (isNaN(current) )
current= 0;
resizeBodyText( current, "n")
function resizeBodyText( factor, reset)
{
if (reset=="y")
factor= (current * -1);
window.alert(cu rrent + " " + factor)
//------------------------------------------------
if (document.all) {
var a = document.all;
var s = '';
current += factor;
var test = "IE!"
if (current < 0)
current = 0;
else
for (var i = a.length-1; i >0;i--)
{
s=a[i].currentStyle.f ontSize+'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].currentStyle.f ontSize)+factor +s;
}
setCookie("font Factor", current)
}
else if (document.getEl ementsByTagName ) {
var a = document.getEle mentsByTagName( "*");
var s = '';
current += factor;
var test = "Netscape 6+!"
if (current < 0)
current = 0;
else
for (var i = a.length-1; i >0;i--)
{
s=a[i].style.fontSize +'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].style.fontSize )+factor+s;
}
setCookie("font Factor", current)
}
else if (document.layer s) {
var a = document.layers ("*");
var s = '';
current += factor;
var test = "Netscape OLD 4!";
if (current < 0)
current = 0;
else
for (var i = a.length-1; i >0;i--)
{
s=a[i].style.fontSize +'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].style.fontSize )+factor+s;
}
setCookie("font Factor", current)
}
window.alert(te st)
}
//-----------------------------------------------
function Right(str, n) {
if (n <= 0)
return "";
else if (n > String(str).len gth)
return str;
else {
var iLen = String(str).len gth;
return String(str).sub string(iLen, iLen - n);
}
}
//-------------------------------------------------
function getCookie(name) {
var dc = document.cookie ;
var index = dc.indexOf(name + "=");
if (index == -1) return null;
index = dc.indexOf("=", index) + 1; // first character
var endstr = dc.indexOf(";", index);
if (endstr == -1) endstr = dc.length; // last character
return unescape(dc.sub string(index, endstr));
}
function setCookie(name, value)
{
document.cookie = name + "=" + escape(value);
}
</script>
</body>
</html>
versions. To go about doing this, it is a definite task. I have it
working in IE(all versions) but it will not increment or decrement the
font size in any other browsers. Any suggestions?
<html>
<head>
</head>
<body>
<h1>Hello there</h1>
<h2>Test</h2>
anything.
<input type="submit" onclick="resize BodyText(2, 'n')" >
<input type="submit" onclick="resize BodyText(-2, 'n')" >
<button type="submit" onclick= "resizeBodyText (0, 'y')" >
<script type="text/javascript">
//-------------------------------------------------
var current = parseInt(getCoo kie("fontFactor "))
if (isNaN(current) )
current= 0;
resizeBodyText( current, "n")
function resizeBodyText( factor, reset)
{
if (reset=="y")
factor= (current * -1);
window.alert(cu rrent + " " + factor)
//------------------------------------------------
if (document.all) {
var a = document.all;
var s = '';
current += factor;
var test = "IE!"
if (current < 0)
current = 0;
else
for (var i = a.length-1; i >0;i--)
{
s=a[i].currentStyle.f ontSize+'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].currentStyle.f ontSize)+factor +s;
}
setCookie("font Factor", current)
}
else if (document.getEl ementsByTagName ) {
var a = document.getEle mentsByTagName( "*");
var s = '';
current += factor;
var test = "Netscape 6+!"
if (current < 0)
current = 0;
else
for (var i = a.length-1; i >0;i--)
{
s=a[i].style.fontSize +'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].style.fontSize )+factor+s;
}
setCookie("font Factor", current)
}
else if (document.layer s) {
var a = document.layers ("*");
var s = '';
current += factor;
var test = "Netscape OLD 4!";
if (current < 0)
current = 0;
else
for (var i = a.length-1; i >0;i--)
{
s=a[i].style.fontSize +'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].style.fontSize )+factor+s;
}
setCookie("font Factor", current)
}
window.alert(te st)
}
//-----------------------------------------------
function Right(str, n) {
if (n <= 0)
return "";
else if (n > String(str).len gth)
return str;
else {
var iLen = String(str).len gth;
return String(str).sub string(iLen, iLen - n);
}
}
//-------------------------------------------------
function getCookie(name) {
var dc = document.cookie ;
var index = dc.indexOf(name + "=");
if (index == -1) return null;
index = dc.indexOf("=", index) + 1; // first character
var endstr = dc.indexOf(";", index);
if (endstr == -1) endstr = dc.length; // last character
return unescape(dc.sub string(index, endstr));
}
function setCookie(name, value)
{
document.cookie = name + "=" + escape(value);
}
</script>
</body>
</html>
Comment