?
Solved

window.resizeto not working chrome

Posted on 2012-04-01
2
Medium Priority
?
2,018 Views
Last Modified: 2012-05-07
Hey All of You ,
I am having this problem that
window.resizeto is  not working in  chrome
how ever it works fine with IE
here is the code
 
<script type="text/javascript">

window.onresize = resize;

function resize()
{
 
    window.resizeTo(screen.width, screen.height);
alert("rezied !")
}



</script>

Open in new window

0
Comment
Question by:AhmedHindy
2 Comments
 
LVL 7

Accepted Solution

by:
designatedinitializer earned 1000 total points
ID: 37793861
Please notice that browsers usually block your javascript from resizing a tabbed window...
For instance, the following will work only if in a standalone window.
Notice that in this script I'm delaying the execution of the resize in order to avoid multiple consecutive resizes due to lag in the firing-off of the events:
<html>
<head>
<script type="text/javascript">
	window.onresize = doResize;
	var interv;
	function doResize(){
		window.clearInterval(interv);
		interv = window.setInterval("resize()",500);
	}
	function resize()
	{
		window.moveTo(0, 0);
		window.resizeTo(screen.width, screen.height);
		alert("resizzzed !");
		window.clearInterval(interv);
	}
</script>
<body>
<p>I'm too sexy for my &lt;body&gt;.</p>
</body>
</html>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37936214
Looking at this script, I suggest the following changes to adhere to best practices

<html>
<head>
<script type="text/javascript">
	window.onresize = function() { // no need to name the function if that is all you do in the event
		// do not use interval if you do not need interval
                // using quotes in a timeout/interval is an implicit EVAL and not good practice
		window.setTimeout(resize,500); 
	}
	function resize() {
		window.moveTo(0, 0);
		window.resizeTo(screen.width, screen.height);
	}
</script>
<body>
.
.
</body>
</html>

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses
Course of the Month16 days, 20 hours left to enroll

864 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