469,288 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,288 developers. It's quick & easy.

Resize text onLoad

Hi,
I am configurating this guestbook that shows text way too big. I have tried
with style sheets and font tags, but they are ignored (not the font, but the
size). I figure a javascript could do it, but I haven't found an applicable
script anywhere. I do think it would be rather straightforward though. I
want the text to be set to x-small (or a relative zoom level) immediately on
load. Anyone that has a script ready?

Regards,

--
Lars Forslin

http://www.connect.to/forslin

"Doing time on Earth"

**************************
Jul 20 '05 #1
3 5438
"Lars Forslin" <la***********************@home.se> writes:
I am configurating this guestbook that shows text way too big. I have tried
with style sheets and font tags, but they are ignored (not the font, but the
size).
Probably because the code contains something like <font size="+7">.
If that is the case, drop the crap. It's either ancient or written
by somebody not familiar with modern web design.

Alternatively, it might contain elements with an attribute
style="font-size:huge"
or something.
I figure a javascript could do it, but I haven't found an applicable
script anywhere. I do think it would be rather straightforward though. I
want the text to be set to x-small (or a relative zoom level) immediately on
load. Anyone that has a script ready?


Guesses, if it is font tags::

1) find font tags. Remvove the size attribute:
<script type="text/javascript">
function removeFont(){
var fonts = document.getElementsByTagName("font");
for (var i=0;i<fonts.length;i++) {
var font = fonts[i];
font.size = "";
font.setAttribute("size","");
}
}
</script>

2) find and remove font tags using DOM:
<script type="text/javascript">
function removeFont(){
var fonts = document.getElementsByTagName("font");
for (var i=0;i<fonts.length;i++) {
var font = fonts[i];
var next = font.nextSibling;
var parent = font.parentNode;
while(font.hasChildNodes) {
var last = font.lastChild;
parent.insertBefore(last,next);
next = last;
}
}
}
</script>

Code not tested (no pages with <font> available).

Run it from the onload handler.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Thanks a lot for the suggestions and swift answers. After I wrote I found
this script which I implemented so it looks like this:

<body style="background-color:transparent" class="brodtext">
<INPUT ID="zoomfactor" TYPE="text" VALUE="50" SIZE="3" MAXLENGTH="4"
onkeyup="updateZoom()">%

<DIV ID="container">

<!--- Don't modify the cgi tag --->
<cgi>
<!--- Don't modify the cgi tag --->
</DIV>
<SCRIPT LANGUAGE="JavaScript">
<!--
function updateZoom() {
container.style.zoom = zoomfactor.value + "%";
}
// -->
</SCRIPT>

<P align="center"><a href="javascript:history.back(1)" class="adress">Back
to guestbook form</a>
</p>

</body>
It does what it should, it works, but I don't want the user to have to write
in a value. I want this to happen onload automatically with a standard value
of 70%. Can you rewrite this for me?
Many thanks
Lars
"Lasse Reichstein Nielsen" <lr*@hotpop.com> skrev i meddelandet
news:k7**********@hotpop.com...
"Lars Forslin" <la***********************@home.se> writes:
I am configurating this guestbook that shows text way too big. I have tried with style sheets and font tags, but they are ignored (not the font, but the size).
Probably because the code contains something like <font size="+7">.
If that is the case, drop the crap. It's either ancient or written
by somebody not familiar with modern web design.

Alternatively, it might contain elements with an attribute
style="font-size:huge"
or something.
I figure a javascript could do it, but I haven't found an applicable
script anywhere. I do think it would be rather straightforward though. I
want the text to be set to x-small (or a relative zoom level) immediately on load. Anyone that has a script ready?


Guesses, if it is font tags::

1) find font tags. Remvove the size attribute:
<script type="text/javascript">
function removeFont(){
var fonts = document.getElementsByTagName("font");
for (var i=0;i<fonts.length;i++) {
var font = fonts[i];
font.size = "";
font.setAttribute("size","");
}
}
</script>

2) find and remove font tags using DOM:
<script type="text/javascript">
function removeFont(){
var fonts = document.getElementsByTagName("font");
for (var i=0;i<fonts.length;i++) {
var font = fonts[i];
var next = font.nextSibling;
var parent = font.parentNode;
while(font.hasChildNodes) {
var last = font.lastChild;
parent.insertBefore(last,next);
next = last;
}
}
}
</script>

Code not tested (no pages with <font> available).

Run it from the onload handler.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #3
As you might suspect I am a novice in this field. I took a look at the
scripts you provided and I have a few questions concerning the first script:
1) Where do I place it? In <head> or <body>?
2) Am I supposed to write the desired font size in: font.size = "";?
3) What about: font.setAttribute("size",""); - should I enter something
here?
Regards,
Lars

"Lars Forslin" <la***********************@home.se> skrev i meddelandet
news:0u********************@newsc.telia.net...
Thanks a lot for the suggestions and swift answers. After I wrote I found
this script which I implemented so it looks like this:

<body style="background-color:transparent" class="brodtext">
<INPUT ID="zoomfactor" TYPE="text" VALUE="50" SIZE="3" MAXLENGTH="4"
onkeyup="updateZoom()">%

<DIV ID="container">

<!--- Don't modify the cgi tag --->
<cgi>
<!--- Don't modify the cgi tag --->
</DIV>
<SCRIPT LANGUAGE="JavaScript">
<!--
function updateZoom() {
container.style.zoom = zoomfactor.value + "%";
}
// -->
</SCRIPT>

<P align="center"><a href="javascript:history.back(1)" class="adress">Back
to guestbook form</a>
</p>

</body>
It does what it should, it works, but I don't want the user to have to write in a value. I want this to happen onload automatically with a standard value of 70%. Can you rewrite this for me?
Many thanks
Lars
"Lasse Reichstein Nielsen" <lr*@hotpop.com> skrev i meddelandet
news:k7**********@hotpop.com...
"Lars Forslin" <la***********************@home.se> writes:
I am configurating this guestbook that shows text way too big. I have tried with style sheets and font tags, but they are ignored (not the font, but
the
size).


Probably because the code contains something like <font size="+7">.
If that is the case, drop the crap. It's either ancient or written
by somebody not familiar with modern web design.

Alternatively, it might contain elements with an attribute
style="font-size:huge"
or something.
I figure a javascript could do it, but I haven't found an applicable
script anywhere. I do think it would be rather straightforward though.
I want the text to be set to x-small (or a relative zoom level)

immediately on load. Anyone that has a script ready?


Guesses, if it is font tags::

1) find font tags. Remvove the size attribute:
<script type="text/javascript">
function removeFont(){
var fonts = document.getElementsByTagName("font");
for (var i=0;i<fonts.length;i++) {
var font = fonts[i];
font.size = "";
font.setAttribute("size","");
}
}
</script>

2) find and remove font tags using DOM:
<script type="text/javascript">
function removeFont(){
var fonts = document.getElementsByTagName("font");
for (var i=0;i<fonts.length;i++) {
var font = fonts[i];
var next = font.nextSibling;
var parent = font.parentNode;
while(font.hasChildNodes) {
var last = font.lastChild;
parent.insertBefore(last,next);
next = last;
}
}
}
</script>

Code not tested (no pages with <font> available).

Run it from the onload handler.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'


Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Michael Satterwhite | last post: by
3 posts views Thread by John | last post: by
5 posts views Thread by Doug Gunnoe | last post: by
3 posts views Thread by Jills | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.