Newbie - Resize Browser Window on Page Load

S

Seefor

Hi, I want to resize the browser window when my web page loads (don't worry,
this is for a private site, so it's not going to piss off a lot of users).

However, the code I have resizes the window fine, but it PERMANENTLY sets
the size of the browser window, so when I open IE again, it defaults to the
size I set.

I've tried the following, but no luck:

<html>
<head>
<title>Page Title</title>
<script type="text/javascript">
<!--
var oldWidth = window.innerWidth;
var oldHeight = window.innerHeight;

function init()
{
window.resizeTo(400, 400);
}

function deinit()
{
window.resizeTo(oldWidth, oldHeight);
}
//-->
</script>
</head>
<body onLoad="init()" onunload="deinit()">
</body>
</html>

I want to TEMPORARILY change the size of the browser window for this page
only.
Is this possible?
 
V

VK

Seefor said:
I want to TEMPORARILY change the size of the browser window for this page
only.
Is this possible?

Not really. It's not a JavaScript problem, it's a browser setting. It
memorizes the size of the the last closed window during the session and
the next session starts with the window of the same size. Something
like that... or close to it... In Internet Explorer it gets sometimes
really annoying and I still did not get the exact system.
 
S

Seefor

VK said:
Not really. It's not a JavaScript problem, it's a browser setting. It
memorizes the size of the the last closed window during the session and
the next session starts with the window of the same size. Something
like that... or close to it... In Internet Explorer it gets sometimes
really annoying and I still did not get the exact system.

Ok, is it possible to somehow create a hyperlink which runs an external .js
file? which can also take parameters? e.g. like:

<a href="http://www.mysite.com/launch.js?param=5">Click Here</a>

This will then run the launch.js script which could open up a popup window?

Basically, I want to be able to give web hosters a very simple URL which
they can add to their sites which will bring up a popup window of size 400
by 400. I don't want the web hosters to have to add any javascript code to
their sites to be able to do this.
 
R

Randy Webb

Seefor said the following on 11/29/2005 6:50 AM:
Ok, is it possible to somehow create a hyperlink which runs an external .js
file? which can also take parameters? e.g. like:

Not exactly the way you describe it but close to what you are describing.

Make it a page on your server that does whatever it is you want to do.

<a href="http://....../myPage.php?param=5">Open myPage.php</a>

And then have myPage.php do whatever it is you are wanting to do.
This will then run the launch.js script which could open up a popup window?

Popup Blockers.
Basically, I want to be able to give web hosters a very simple URL which
they can add to their sites which will bring up a popup window of size 400
by 400. I don't want the web hosters to have to add any javascript code to
their sites to be able to do this.

And how do you propose that they execute *any* script without having to
add code? And what is this 400x400 window for? And, how do you know that
400x400 is a suitable size window for the *user*?
 
S

Seefor

Ok, well the best I've come up with is to have two pages - one called
Launcher.aspx, and one called MyPage.aspx (which is the actual page I want
to display in the pop up window).

The web hoster adds the following link to their web page:

<a href="http://www.myserver.com/Launcher.aspx?id=4" target="_blank">Click
Here</a>

The Launcher.aspx gets the list of paramters (the ?id=4 on the end), and
then appends them onto 'MyPage.aspx' and opens a popup window with that
page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Title</title>
<script type="text/javascript">
<!--
var newwindow = '';

function popitup(url)
{
if (!newwindow.closed && newwindow.location)
{
newwindow.location.href = url;
}
else
{
newwindow = window.open(url,'name','height=400,width=400');
if (!newwindow.opener)
{
newwindow.opener = self;
}
}
if (window.focus)
{
newwindow.focus()
}

return false;
}

function init(newPage)
{
// get just the parameters
var loc = location.href;
var startIndex = loc.indexOf("?");

if (startIndex != -1)
{
var params = loc.substring(startIndex, loc.length);

if (params.length > 0)
{
var newLocation = newPage + params;

// open popup window
popitup(newLocation);
}
}
}

//-->
</script>
</HEAD>
<body onLoad="init('MyPage.aspx')">
</body>
</HTML>

Then MyPage.aspx closes the Launcher.aspx page thus:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Title</title>
<script type="text/javascript">
<!--
function init()
{
opener.opener = top;
opener.close();
}
//-->
</script>
</HEAD>
<body onLoad="init()">
[ASPX CODE TO LOAD THE APPROPRIATE DATA BASED ON ID PARAMETER]
</body>
</HTML>

This works fine except that a blank white page is displayed for about a
second (Launcher.aspx) before the popup window is displayed (MyPage.aspx).

I don't know of a way around this. Any suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top