Solved

Automatically resize IE to fit text

Posted on 2003-11-04
3
344 Views
Last Modified: 2008-02-01
Good day

I have this header in my html page , e.g. STANS REPAIR SHOP
I have set this html page size to say 500,400
If i open this page after i tested it , it says "STANS REPAIR SHOP" proudly left in the page
However when someone on another pc opens  it. it says
"STANS REPAIR
 SHOP"

how can i set IE to automatically resize the page so that the "STANS REPAIR SHOP"
will always display in its full length?
0
Comment
Question by:jxharding
3 Comments
 
LVL 3

Expert Comment

by:monvelasquez
ID: 9685002
you can use javascript when the page loads...

<HTML>
...
<body onload="resizeTo(500,400);">
...
</body>
</HTML>
0
 
LVL 11

Accepted Solution

by:
Zontar earned 50 total points
ID: 9685786
People don't usually like having their browser windows resized for them.

Here's a better solution -- resize the text to fit the user's window:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>

<style type="text/css">
  h1#pageTitle  {font:bold normal 15px Arial,Helvetica,sans-serif; text-align:center;}
</style>

<script type="text/javascript">

window.onload = fitHeading;
window.onresize = fitHeading;

function fitHeading()
{
  var adjust = 12;
  var heading = document.getElementById("pageTitle");
  var pageWidth = document.body.offsetWidth;
 
  heading.style.fontSize = Math.floor(pageWidth/adjust) + "px";
}
</script>

</head>
<body>
<h1 id="pageTitle">STAN'S REPAIR SHOP</h1>
</body>
</html>

Change the value for the "adjust" variable to get it just the way you want it.

Works in MSIE and Mozilla -- should work in all the version 5 and higher browsers.
0
 

Author Comment

by:jxharding
ID: 9685842
thanks a lot! , will try & accept
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now