473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 5582
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Rob | last post by:
Hi, I have some problems resizing a html page when it is loaded. I want the page to resize to the screensize. The following snipped of code (see below) works perfect on my Windows NT. but not...
9
by: Don | last post by:
Does anyone know where I can find a client-side function I can reference from within an HTML/JavaScript web page? I'm currently using a core PHP function to do this, but I'd rather do it on the...
8
by: Michael Satterwhite | last post by:
I'm opening a page that has a single image on it. I'd like to resize the window containing the image to the size of the image (slightly larger OK, not smaller). The width isn't a problem, but the...
3
by: John | last post by:
Hi, This is my first experiment with C#, I'm trying to handle the resize event. According to the documentation I should handle the Layout event for this. My question is: how do I register this...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
2
by: wolfing1 | last post by:
Maybe this doesn't make any sense, but is it possible to dynamically resize an iframe to the height of its contained page? Something that works in Opera/Firefox/IE. I can resize it with a...
4
by: DeanJo | last post by:
I am trying to develop a resize module i can include on my pages that calculates the size of input fields based on the screen resolution... I can already detect the screen resolution, and i have...
5
by: Doug Gunnoe | last post by:
I'm considering resizing a div onload to better match the screen width of the user. Easy enough, however it seems that I have read in this group that there are potential problems with this,...
3
by: Jills | last post by:
Hi All, Does anyone have any idea about how can we resize an IFRAME dynamically according to its content from another domain? I want to increase the height according to the page that is...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.