Having PHP load open pre-sized window?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Having PHP load open pre-sized window?

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Post 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?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
Last edited by JayBird on Tue Sep 02, 2003 11:11 am, edited 1 time in total.
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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 ;)
Post Reply