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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE6 MinWidth Fix

Status
Not open for further replies.

MaxGeek

Technical User
Jan 8, 2004
52
US
Can someone link me to some good MinWidth Javascript fixes?

I have been using the one from but it has problems with my design where if I made the window smaller then the minwidth and then clicked the maximize button I would be missing my main content div.
 
One way to do this is with behaviours (or behaviors, if you're from across the pond ;o).

Stick this in your head section:

Code:
<head>
<!--[if IE]>
	<link href="ieMinWidthFix.css" type="text/css" rel="stylesheet" />
<![endif]-->
</head>

then create a css file, ieMinWidthFix.css (or whatever you want to call it), which contains:

Code:
body {
	behavior: url(ieMinWidthFix.htc);
}

Then, create the file ieMinWidthFix.htc - this is a plain text file. It contains JavaScript:

Code:
<public:component lightweight="true">

	<public:attach event="ondocumentready" onevent="resizeMe()" />
	<public:attach event="onresize" for="window" onevent="resizeMe()" />

	<script type="text/javascript">
	<!--
		function resizeMe() {

			if (window.document.getElementsByTagName('html')[0].clientWidth < 760) {
				element.style.width = '740px';
			} else {
				element.style.width = 'auto';
			}
		}
	//-->
	</script>
</public:component>

You can change the values to suit your own needs.

The beauty of this solution is that it doesn't even get downloaded for non-IE browsers, so in that respect is a lot better than including a JS file on the page.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hehe.. of course, a neater way (from me) would have been to pick up on any min-width property from the relevant element. But I just wanted a quick fix at the time. You could look into that, if you wanted ;o)

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for the help. The only problem I have now is that the height seems affected by the minwidth script too. So while you are inside the minwidth you have to scroll to see the footer, but its not that big of a deal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top