JavaScript and Buttons

 

Suppose that in a movie, you wish a user, clicking a button, 'd open a new window in the browser but this window must have its size well defined to contain an image.
Suppose the button has been built. For instance,

Reduce the button tree :

In the right zone, click tab Actions, then Add Event, then On Press
Then click Add Action, then JavaScript

The purpose, while clicking button, is to call the script plan.php in a new page with a fixed size.
( Right here, we don't worry with the position of the window on screen )
Then, in the edit field named Javascript, enter
window.open('http://www.monsite.com/plan.php','newwin', 'width=681,height=681, toolbar=no,location=no,directories=no, status=no,menubar=no,scrollbars=yes,resizable=no');
void(0);

The content of the script plan.php could be, for instance :
<HTML><BODY marginwidth='0' topmargin='0' leftmargin='0' marginheight='0'> <IMG SRC='swish/images/plan1.jpg' width='681' height='681' border='0'> </BODY></HTML>

And, as a bonus, same thing, centered on screen :
window.open('http://www.monsite.com/plan.php','newwin', 'width=681,height=681, toolbar=no,location=no,directories=no, status=no,menubar=no,scrollbars=yes,resizable=no, top='+((screen.availHeight/2)-(681/2))+',left='+((screen.availWidth/2)-(681/2))+'');
void(0);

 


Si vous aimez le site

 

Select a language if you need :


Page chargée en 0.003 sec.

Dernière Modification : Mer 25 Janvier 2017 8:56
Copyright © 1999-2017 Jean-Paul Molina Tous droits réservés.

to Google