Forum Moderators: open

Message Too Old, No Replies

Quick resize window issue

         

ahmedtheking

3:46 pm on May 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can someone figure out why this isn't working?

function resizeWindow () {
// get image size first
//var h = $('image').height;
var h = document.images[0].height;
//var w = $('image').width;
var w = document.images[0].width;

// resize window!
window.resizeTo(h,w);

}

window.setTimeout('resizeWindow()',500);

(the image is present and it can read the size. But it doesn't resize the window though!)

Dabrowski

4:26 pm on May 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Silly question, it's not in a tabbed or maximised browser?

ahmedtheking

6:16 pm on May 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, it's in a popup window.

Dabrowski

12:55 am on May 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then no, I don't know why it's not working. But try this popup-friendly popup.....

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<title>Test Page</title>
<style>

HTML, BODY { height: 100%; margin: 0;}
.content { padding: 10px; }

#popup {
position: absolute;
left: 0; top: 0;
width: 100%; height: 100%;
display: none;
}

#popup .back {
position: absolute;
left: 0; top: 0;
width: 100%; height: 100%;
background: black;
filter: alpha( opacity=60);
opacity: .6;
}

#popup .content {
position: relative; float: left;
margin: 100px 0 0 100px;
width: 200px; height: 200px;
background: white;
border: 2px solid blue;
}

</style>

<script>

function popup() {
var div = document.getElementById( "popup");
div.style.display = "block";
}

function nopopup() {
var div = document.getElementById( "popup");
div.style.display = "none";
}

</script>

</head>

<body>

<div class='content'>
<h1>Non-Popup Popup</h1>
<p><a href='#' onClick='popup();'>Click here</a> for the popup!</p>
<p>Praesent turpis arcu, aliquam ut, elementum at, pellentesque in, lorem. Nullam blandit tellus quis massa. Fusce eu orci. Etiam scelerisque risus vitae tellus. Morbi lorem turpis, sollicitudin vel, nonummy id, laoreet eget, tellus. Pellentesque purus. Duis facilisis. Nullam ultrices eros ac lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nullam turpis arcu, bibendum sit amet, rutrum non, lacinia vitae, dolor. Praesent dignissim mi non urna. Quisque non eros. Donec est velit, iaculis id, consequat sit amet, tempor ut, sapien. Sed convallis vehicula purus. Sed a sapien ac nunc porttitor venenatis. Proin gravida mi nec augue. Phasellus tellus. Aenean euismod dolor vel nisl.</p>
<p>Nam at justo. Nulla ultrices vehicula odio. Cras sollicitudin quam eu tellus. Ut id leo. Fusce lorem. Pellentesque sodales, diam at ornare fringilla, nibh eros lacinia orci, eu tincidunt diam ipsum quis massa. Duis nisl risus, placerat scelerisque, pharetra quis, molestie id, massa. Maecenas sagittis. Morbi venenatis elementum ligula. Suspendisse a dolor. In vel sem. Nam ipsum.</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus at ipsum. Integer ultricies, metus dignissim tristique consequat, enim massa aliquam libero, ut mollis sapien metus at diam. Etiam consectetuer, mi sit amet semper ullamcorper, est orci elementum tellus, vitae aliquam ipsum erat a erat. Etiam non justo vitae mauris tempus blandit. Quisque iaculis posuere turpis. Aliquam pulvinar, mauris varius porta gravida, tellus enim semper mauris, ut lacinia nunc est convallis tortor. Nunc at tortor. Duis consectetuer pulvinar lacus. Vestibulum eget ante. Phasellus purus. Mauris orci enim, dignissim eu, suscipit cursus, ornare vitae, enim. Sed vitae risus. Vestibulum interdum mollis magna. Sed aliquet, arcu eget hendrerit ornare, orci diam commodo odio, eu fringilla ante erat vitae nisi. Nulla dignissim ipsum nec purus.</p>
</div>

<div id='popup'>
<div class='back'></div>
<div class='content'>
<p>Sick of looking at this popup?</p>
<p><a href='#' onClick='nopopup();'>Click here!</a></p>
</div>
</div>

</body>

</html>

ahmedtheking

8:44 am on May 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah that's nice! Thanks for that!

Drag_Racer

9:12 am on May 15, 2007 (gmt 0)

10+ Year Member



the only thing I can think of is maybe the variable are not recognized as integers, but maybe strings, as resizeTo requires integers only.

try forcing them to integers and see what happens

also take this to note...

Windows Internet Explorer 7. This method is only effective when a single tab is open or when tabbed browsing is disabled. If multiple tabs are open, this method is blocked.

Dabrowski

1:03 pm on May 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I stopped using move and resize because of tabbed browsing, and also popups cos these days they never actually pop up. That's why I wrote that popup above. Looks better anyway!