T
tlendz
Hi,
I've got several divs with the same id/name, and text inside (font-
family:georgia,serif), and would like the users to be able to change
the font, in case they don't like the default one. I have come up with
this code, however it updates the divs' style only once, to 'arial',
whereas I would like them to be switched to 'times new roman',
'verdana', back to 'georgia', and so on. All with consecutive click on
a single link:
<a href="javascript:fontnew();\>Change Font</a>>
function fontnew() {
var div;
var newfamily;
if (!done) { var done; }
done = 0;
if (!newfamily) { newfamily = 'georgia,serif'; }
if (done==0 && newfamily == 'georgia,serif') { newfamily = 'arial';
done = 1; }
if (done==0 && newfamily == 'arial') { newfamily = 'times new roman';
done = 1; }
if (done==0 && newfamily == 'times new roman') { newfamily =
'verdana'; done = 1; }
if (done==0 && newfamily == 'verdana') { newfamily ==
'georgia,serif'; done = 1; }
var divs = document.getElementsByName('M');
for (i = 0; i < divs.length; i++) {
div = divs;
div.style.fontFamily = newfamily;
}
}
Any suggestions?
Take care!
I've got several divs with the same id/name, and text inside (font-
family:georgia,serif), and would like the users to be able to change
the font, in case they don't like the default one. I have come up with
this code, however it updates the divs' style only once, to 'arial',
whereas I would like them to be switched to 'times new roman',
'verdana', back to 'georgia', and so on. All with consecutive click on
a single link:
<a href="javascript:fontnew();\>Change Font</a>>
function fontnew() {
var div;
var newfamily;
if (!done) { var done; }
done = 0;
if (!newfamily) { newfamily = 'georgia,serif'; }
if (done==0 && newfamily == 'georgia,serif') { newfamily = 'arial';
done = 1; }
if (done==0 && newfamily == 'arial') { newfamily = 'times new roman';
done = 1; }
if (done==0 && newfamily == 'times new roman') { newfamily =
'verdana'; done = 1; }
if (done==0 && newfamily == 'verdana') { newfamily ==
'georgia,serif'; done = 1; }
var divs = document.getElementsByName('M');
for (i = 0; i < divs.length; i++) {
div = divs;
div.style.fontFamily = newfamily;
}
}
Any suggestions?
Take care!