Solved

window.resizeto not working chrome

Posted on 2012-04-01
2
1,508 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 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now