Click to See Complete Forum and Search --> : Popup size


neil9999
07-14-2003, 10:12 AM
Hi,

How can I change the height and width of a popup by clicking a button without reloading the page?

Thanks,

Neil

JHL
07-14-2003, 10:26 AM
window.resizeTo(x,y)

neil9999
07-14-2003, 02:27 PM
Thanks,

When I change the window size by clicking the button, can I also reposition the window on the screen?

Neil

neil9999
07-14-2003, 03:07 PM
Also, i'd like a close button on the page. When you click on it, it should say 'Are you sure you want to close this window? Ok/Cancel'. OK should close the window, and Cancel should keep the window open.

Thanks,

Neil

neil9999
07-15-2003, 10:26 AM
1 more thing: is is possible to change the formatting in an alert?

Thanks,

Neil

MadCommando
07-15-2003, 11:13 AM
I know the window move is possible, though I forgot the exact script, if you ever are searching the web and find a popup window "shaking" around it's moving it's coordinates you can then rip off the code and you're set.

as for your closing the popup

put this code in it.

<script>
function closebutton()
{
if (confirm("Close the window?") )

{
self.close()
}
}
</script>
<body>
<input type=button value="Close this Window" onClick="closebutton()">



And that should work, if you do a little searching around you can probably find how to move the window.

neil9999
07-15-2003, 11:19 AM
Thanks, that works. Do you know about the formatting the alert? (I know you can do it with VB script, but as that only is supported by IE that wouldn't be any use).

Thanks,

Neil

SlankenOgen
07-15-2003, 11:29 AM
myWin.resizeTo(a, b);

myWin.moveTo(x, y);

neil9999
07-15-2003, 12:14 PM
Thanks, but I can't get it to work. Can you show me how to resize the current window when you load a page?

Neil

SlankenOgen
07-16-2003, 05:51 AM
Can you post the code you are using?

neil9999
07-16-2003, 11:38 AM
Here it is:


<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Resize</title>
</head>

<body onload='myWin.resizeTo(640, 450), myWin.moveTo(0, 0),' bgcolor="#C0C0C0">

<p>Resize</p>

</body>

</html>



Thanks,

neil

SlankenOgen
07-16-2003, 12:00 PM
You need to do it like this-

function A(){

var w = window.open(" etc.................

resetWin();

}

function resetWin(){

if(w && w.open){

w.resizeTo........
w.moveTo........

return;

}else{

resetWin();

}
}

If you want to resize it with a link put the resetWin function in the popup you want to resize and use-

<a href ="#" onclick = "return resetWin()">resize</a>

neil9999
07-16-2003, 12:17 PM
Sorry, i can't see how to put this into my code. Please could you write the code for a page in a popup, which when you open it it resizes to 640x480 and moves to 0,0?

Thanks,

Neil

SlankenOgen
07-16-2003, 01:09 PM
Yes, can you post the entire javascript + html in the popup?

neil9999
07-16-2003, 02:40 PM
Same as what is above

Neil

SlankenOgen
07-17-2003, 06:15 AM
<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Resize</title>


<script type = "text/javascript">

function winStuff(a, b, m, n){

self.resizeTo(a, b);
self.moveTo(m, n);

}

</script>
</head>

<body onload="winStuff(640, 450, 0, 0)" bgcolor="#C0C0C0">

<p>Resize</p>

</body>

</html>

neil9999
07-17-2003, 10:38 AM
Thanks alot. It works perfectly now. Do you know if it's possible to format an alert with JavaScript?

Thanks again,

Neil

SlankenOgen
07-17-2003, 10:41 AM
You're welcome.

I believe only very basic html can be used with alerts like <b></b> etc.

pyro
07-17-2003, 10:46 AM
You can't use any html with alerts... ie. alert ("<b>this is a test</b>"); will alert <b>this is a test</b> rather than this is a test

If you want a new line, you can use \n, but you are fairly limited other than that...