Solved

window.resizeto not working chrome

Posted on 2012-04-01
2
1,733 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 invoke it on a web page. 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.: (CODE)

691 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