Interesting

  • Thread starter jfancy-Transport Canada
  • Start date
J

jfancy-Transport Canada

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="resizeBodyText(2, 'n')" >
<input type="submit" onclick="resizeBodyText(-2, 'n')" >
<button type="submit" onclick= "resizeBodyText(0, 'y')" >


<script type="text/javascript">
//-------------------------------------------------


var current = parseInt(getCookie("fontFactor"))
if (isNaN(current))
current= 0;

resizeBodyText(current, "n")
function resizeBodyText(factor, reset)
{
if (reset=="y")
factor= (current * -1);

window.alert(current + " " + 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.currentStyle.fontSize+'';
s=Right(s,2);
a.style.fontSize = parseInt(a.currentStyle.fontSize)+factor+s;
}
setCookie("fontFactor", current)
}
else if (document.getElementsByTagName) {
var a = document.getElementsByTagName("*");
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.style.fontSize+'';
s=Right(s,2);
a.style.fontSize = parseInt(a.style.fontSize)+factor+s;
}
setCookie("fontFactor", current)
}
else if (document.layers) {
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.style.fontSize+'';
s=Right(s,2);
a.style.fontSize = parseInt(a.style.fontSize)+factor+s;
}
setCookie("fontFactor", current)
}
window.alert(test)
}


//-----------------------------------------------
function Right(str, n) {
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(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.substring(index, endstr));
}
function setCookie(name, value)
{
document.cookie= name + "=" + escape(value);
}

</script>

</body>
</html>
 
L

Lee

jfancy-Transport Canada said:
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?

Most browsers already have a menu option and/or shortcut key to
increment/decrement the font size. Why add another thay may or
may not work?
 
R

Randy Webb

jfancy-Transport Canada said:
Don't ask me, ask Transport Canada.

But you are representing them, you are supposedly the competent
authority on the matter, it is *your* duty to explain to Transport
Canada that its a stupid idea.

Please read the group FAQ, thoroughly.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
J

jfancy-Transport Canada

Believe me, I already have, but I am a student and I don't think I have
that kind of authority right now!

So, any suggestions or ?
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Wed, 1 Jun 2005 06:00:02, seen in
jfancy-Transport Canada said:
Believe me, I already have, but I am a student and I don't think I have
that kind of authority right now!

So, any suggestions or ?

For proper quoting when using Google for News :-
Keith Thompson wrote in comp.lang.c, message ID
<[email protected]> :-
If you want to post a followup via groups.google.com, don't use
the "Reply" link at the bottom of the article. Click on "show
options" at the top of the article, then click on the "Reply" at
the bottom of the article headers.

Since that is what the experts in this newsgroup prefer to read, it will
be to your advantage to comply.

You have already been told to read the FAQ.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top