<script language="Javascript">
window.onresize = function (){
alert("Thanks for resizing!");
}
</script>

Is there any reason this gets sent twice to IE? Is there anyway I can make it so it will wait until the user is done resizing before it sends it(IE problem)?

Recommended Answers

All 9 Replies

Well, you can make it browser specific:

<script type="text/javascript">

if (navigator.appName == 'Microsoft Internet Explorer') {

 // Only for IE (that poorly made and pathetic little browser):

 var counter = 0;
 window.onresize = function (){
  if (counter == 1) {
   alert("Thanks for resizing!");
   counter--;
  } else {
   counter++;
  }
 }
} else { 

 // For all other (major) browsers:

 window.onresize = function (){
  alert("Thanks for resizing!");
 }
}
</script>

~G

As for your first question, IE will fire the resize even not only for the window but for any Div within the document that resizes. Also it fires for the resize of the width and height. Also IE (depending on version, security patches and os combo's such as ie8 with vista) may prevent you from re-resizing via javascript on the resize event due to "security concerns".

Can I have more then one function in a script? If so how would I go about doing it?

The edit/delete button is not showing up

@Graphix the code you have there still does the same thing mine does

and before I go any further I think I should tell you what Im doing this for

What im looking to do is have javascript check to see if the page has went below 640X480 and if so it would resize it to 640X480. Should I be using javascript or is there a better way?

function checksize() {
    var width = 0, height = 0;
    if( typeof( window ) == 'number' ) {  
    width = window.innerWidth;
    height = window.innerHeight;
  } else if( document ) {
    //IE
    width = document.body.clientWidth;
    height = document.body.clientHeight;
  }
}
<html>
<head>
<title>Javascript Test</title>
<script type="text/javascript">

	//Evertime the user changes the dimensions of the page
	//This script will check to see if it is below 640X480
	//then resize it acordingly

	window.onresize = function resize(){

	checksize();

	if (width < "640") {
	window.resizeTo (640,height)
	}

	else if (height < "480") {
	window.resizeTo (width, 480)
	}
	}

	//This function checks viewable size of the browser

	function checksize() {

	var width = 0, height = 0;  

	if( typeof( window ) == 'number' ) {
	width = window.innerWidth;
	height = window.innerHeight;
	}

	else if( document ) {
	//IE
	width = document.body.clientWidth;
	height = document.body.clientHeight;
	}
	}
</script>
</head>
<body>
</body>
</html>

Any suggestions?? See anything I'm doing wrong? Is there a way to make it so the edit buttons don't disappear??

Still needing help

Your code should be the following, also check out macgurl70's link.

<script type="text/javascript">

if (navigator.appName == 'Microsoft Internet Explorer') {

 // Only for IE (that poorly made and pathetic little browser):

 var counter = 0;
 window.onresize = function (){
  if (counter == 1) {
   ChangeSize();
   counter--;
  } else {
   counter++;
  }
 }
} else { 

 // For all other (major) browsers:

 window.onresize = function (){
  ChangeSize();
 }
}

function ChangeSize() {
	
	var width = 0, height = 0;  

	if (navigator.appName != 'Microsoft Internet Explorer') {

		width = parseInt(window.innerWidth);
		height = parseInt(window.innerHeight);

	} else {

		width = parseInt(document.body.clientWidth);
		height = parseInt(document.body.clientHeight);

	}

	if ((width < 640 && height < 480)) {

		window.resizeTo (640,480)

	} else {

		window.resizeTo (width, height)

	}

}
</script>

Although this code does what you want, when you maximize/minimize the window, it gets messed up. Also it is extremely annoying even if you don't. I recommend you do not use this code because of that.

~G

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.