hi
is it possible to adjust the page width according to the output of the page so that the user doesn't have to scroll to see the end of the page?

You can possibly achieve this by creating a table and setting its width to 100%, this will allow more data to be shown across the page. You can do something like this:

$exampleOuput = "<table width=/"100%/">
<tr>
<td>
..The ouput code here..
</td>
</tr>
</table>";
echo $exampleOutput;

If you want to restrict some page width, then all you have to do is change the width inside the table tag to the page size you want.

P.S 100% width size is a full page width.

This is just an example of how you can do it:)

When displaying things such as large images or content, use a CSS stylesheet and set them to a percentage, instead of a static pixel width.

img {
       width: 40%;
}

its not about images . actually i have to display the output of some command(lets say ls) . i want that the entire output of the command shoud fit in the webpage in such a way that i need not use the vertical scroll bar even if the number of output of the command varies from time to time

Say if the output is of 2 pages. Then how can you output everything in 1 page ? You can specify the width and height of the page, but if the output is more, I dont think you can avoid scroll.

Say if the output is of 2 pages. Then how can you output everything in 1 page ? You can specify the width and height of the page, but if the output is more, I dont think you can avoid scroll.

What you're saying is true. The page will have to be scrolled in some way.

One way that you can get the code to display without having to scroll down the entire page is by using the <iframe></iframe> tag. It's good for keeping pages from becoming massively large, and you can load any content into them. I use them quite often as it helps with load times for dial-up users, and it makes the site more user friendly (IMO).

If you're thinking "how will loading 2 pages at once help dial-up users..." the answer is simple. Yes the first page loaded will be slower, but every page that's loaded after that will be loaded faster because you won't have to load all the template images again, as they'll already be loaded on the main page that has the iframe.

If I were you, I'd try using iframes. It might help you out.

An example of using an iframe can be like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test iframe</title
</head>
<body>
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td><img src="images/top_left_elbow.gif" alt=""></td>
			<td class="topborder" width="100%"></td>
			<td><img src="images/top_right_elbow.gif" alt=""></td>
		</tr>
		<tr>
			<td class="leftborder" width="1%"></td>
			<td width="90%" align="center" class="logo"><img src="images/logo.gif" alt="" border="0"></td>
			<td class="rightborder" width="1%"></td>
		</tr>
		<tr>
			<td><img src="images/bottom_left_elbow.gif" alt=""></td>
			<td class="bottomborder" width="100%"></td>
			<td><img src="images/bottom_right_elbow.gif" alt=""></td>
		</tr>
	</table>
	<table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td width="180" valign="top">
				<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
					<tr>
						<td><img src="images/top_left_elbow.gif" border="0" alt=""></td>
						<td width="100%" class="topborder"></td>
						<td><img src="images/top_right_elbow.gif" border="0" alt=""></td>
					</tr>
					<tr>
						<td class="leftborder"></td>
						<td width="100%">
							<table width="100%" align="center">
								<tr>
									<td><iframe name="content" src="home.html" width="100%" height="100%"></iframe></td>
								</tr>
							</table>
						</td>
						<td class="rightborder"></td>
					</tr>
					<tr>
						<td><img src="images/nav_bottom_left_elbow.gif" alt=""></td>
						<td width="100%" class="bottomborder"></td>
						<td><img src="images/nav_bottom_right_elbow.gif" alt=""></td>
					</tr>
				</table>
			</td>
			<td width="180" valign="top">
				<table width="100%" cellspacing="0" cellpadding="0" border="0">
					<tr>
						<td><img src="images/nav_top_left_elbow.gif" alt="" border="0"></td>
						<td width="100%" class="topborder"></td>
						<td><img src="images/nav_top_right_elbow.gif" alt="" border="0"></td>
					</tr>
					<tr>
						<td width="1%" class="leftborder"></td>
						<td>
							<table width="100%" cellpadding="0" cellspacing="0" border="0">
								<tr>
									<td><a href="linkurl" target="content"></a></td>
								</tr>
							</table>
						</td>
						<td width="1%" class="rightborder"></td>
					</tr>
					<tr>
						<td><img src="images/nav_bottom_left_elbow.gif" border="0" alt=""></td>
						<td width="100%" class="bottomborder"></td>
						<td><img src="images/nav_bottom_right_elbow.gif" border="0" alt=""></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<br>
</html>
This article has been dead for over six months. Start a new discussion instead.