Solved

window.resizeto not working chrome

Posted on 2012-04-01
2
1,576 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

786 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