Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Size window based on html file size

Status
Not open for further replies.

robynne

Programmer
Aug 11, 2001
5
US
Hello, I am creating an input form with various fields. I need to make clickable labels for the fields. When the user clicks on a label (which is a text link), a definition for that item is displayed. I am opening a new window that has the definition. Here's an example of what happens when the user clicks the text link:

Code:
msg=window.open("filewithdefinition.html","","scrollbars=0,menubar=0,height=120,width=300,left=260,top=260");

Is there any way to size the window based on the length of the definition (instead of setting values for the height and width in the window.open method)? For example, when you use the "alert" window, you simply enter the text - the alert window size is based on the amount of text being displayed. Or is there a way to have an alert box read and display (in an alert window) an html file? Thank you for your assistance.
 
You could try to modify the size of the window after you open it, depending on the length of the definition, by using a DIV element, for instance.
Note that you first have to set the width of the element, otherwise you can not read it.

Works with IE, I don't know about other browsers.

Code:
<html>
<body>

<div id = &quot;test&quot; nowrap>
	<h1>Modify this string</h1>
</div>

<script language = &quot;JavaScript&quot;>
	test.style.width = 1
	window.resizeTo(test.clientWidth + 50, 230);
</script>

</body>
</html>

vlad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top