Page 1 of 1

Having PHP load open pre-sized window?

Posted: Tue Sep 02, 2003 10:44 am
by camarosource
I have a html form that someone fills out. Then on "submit" a php script reads what was typed in the form. It then opens a new page with a html page in it with the results.
I would like this page to load as a pre-sized window (ie. 200 X 400pixels). How?

This is how I have it loading the new page:

Code: Select all

$file = "../../../directory/filename.htm";
$read = fopen($file, "r");
$content = fread($read, filesize($file));
$content = ereg_replace("{VIN}", $VIN, $content);
$content = ereg_replace("{make}", $make, $content);
$content = ereg_replace("{serial}", $serial, $content);
echo $content;


I would like this to pop open a pre-sized window rather than an entirely new page..

Thanks.

Posted: Tue Sep 02, 2003 10:46 am
by twigletmac
If you want to do this then you'll have to use JavaScript - PHP can't interact with the client (i.e. the browser).

Mac

Posted: Tue Sep 02, 2003 10:51 am
by camarosource
twigletmac wrote:If you want to do this then you'll have to use JavaScript - PHP can't interact with the client (i.e. the browser).

Mac
I friend wrote a program for me and had a new window load with an image in it. The script he used for the link was

<a href="#newwindow" onclick="window.open('{IMAGE_DIR}/{FULL}','window_1','width={IMG_WIDTH},height={IMG_HEIGHT},scrollbars=yes');return false">
<img border="2" src="{THUMBSCRIPT}?img={FULL}&x=175&y=107"></a>

Does this help? or would it work? If so, how do I implement it into the script and where?

Posted: Tue Sep 02, 2003 11:03 am
by JayBird

Code: Select all

<a href="#newwindow" onclick="window.open('&#123;IMAGE_DIR&#125;/&#123;FULL&#125;','window_1','width=&#123;IMG_WIDTH&#125;,height=&#123;IMG_HEIGHT&#125;,scrollbars=yes');return false"> 
<img border="2" src="&#123;THUMBSCRIPT&#125;?img=&#123;FULL&#125;&x=175&y=107"></a>
Yup, that is just a javascript link which is generated in PHP. PHP doesn't open the new window, thats Javascripts job. PHP fills in the information when the page is processed so the javascript knows what image to open and how big the window should be.

Mark

Posted: Tue Sep 02, 2003 11:05 am
by camarosource
Since the php file is what loads a certain page depending on what they entered in the form, I would need to put the javascript in the php page.

Could you tell me what would be the javascipt and where I would place it? I would assume somewhere in the php code I posted in my first msg.

Posted: Tue Sep 02, 2003 11:25 am
by volka
onClick specifies an event handler that is to be called when the element is clicked. In you case it calles a dom/js-method.
window is a dom-object and open one of its methods.
e.g. take a look at http://www.blooberry.com/indexdot/html/ ... owopen.htm


now the browser/client doesn't care about what produced the output, it only sees the output

Code: Select all

&lt;html&gt;
	&lt;body&gt;
		text
	&lt;/body&gt;
&lt;/html&gt;

Code: Select all

<html>
	<body>
		<?php echo 'text'; ?>
	</body>
</html>

Code: Select all

<?php
$sub = 'xt';
<html>
	<body>
		<?php echo "te{$sub}"; ?>
	</body>
</html>
all above sends the same output to the client.

Combine that and you have (more or less) the code snippet you've posted ;)