?
Solved

window.resizeto not working chrome

Posted on 2012-04-01
2
Medium Priority
?
1,809 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 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 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