Web Hosting Talk







View Full Version : open JAvascript popup from PHP


vientorio
12-27-2003, 10:10 AM
hello there,

I have a small problem with one of our customers PHP script. we mirror files for them and they use a dl.php file to get the file. When this dl.php file is displayed in a web browser we need it to open a pop up window

the top of the PHP file is as follows

print("<html>
<head>
<TITLE>Downloading...</TITLE>
<style type=\"text/css\">
<!--
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: none;}
a:hover{color:red}
-->
</style>

</head>



we need to insert a link like this:

<SCRIPT LANGUAGE="JavaScript" src="URL/assign.php?l=vientorio&mode=behind"> </script>

Many thanks in advance for any help

Regards,
Geoff :)

digitok
12-27-2003, 10:23 AM
You mean popup a new site?...

echo '<script type="text/javascript">window.open(\'URL/assign.php?l=vientorio&mode=behind\');</script>';

vientorio
12-27-2003, 10:36 AM
Yes a new site... I added the script you specify like this

<?php

print("<html>
<head>
echo '<script type="text/javascript">window.open(\'httpmyurl/assign.php?l=vientorio&mode=behind\');</script>';
<TITLE>Downloading...</TITLE>
<style type=\"text/css\">
<!--
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: none;}
a:hover{color:red}
-->
</style>

</head>


But i get this error

Parse error: parse error, unexpected T_STRING in C:\Inetpub\Mirrors\dl.php on line 5


line 5 is this:

echo '<script type="text/javascript">window.open(\'httpmyurl/assign.php?l=vientorio&mode=behind\');</script>';


Many thnaks i am closer now than ever
httpmyurl is the domain, i cannot post urls yet

Rich2k
12-27-2003, 11:39 AM
Originally posted by vientorio
Yes a new site... I added the script you specify like this

<?php

print("<html>
<head>
echo '<script type="text/javascript">window.open(\'httpmyurl/assign.php?l=vientorio&mode=behind\');</script>';
<TITLE>Downloading...</TITLE>
<style type=\"text/css\">
<!--
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: none;}
a:hover{color:red}
-->
</style>

</head>


But i get this error

Parse error: parse error, unexpected T_STRING in C:\Inetpub\Mirrors\dl.php on line 5


line 5 is this:

echo '<script type="text/javascript">window.open(\'httpmyurl/assign.php?l=vientorio&mode=behind\');</script>';


Many thnaks i am closer now than ever
httpmyurl is the domain, i cannot post urls yet

You need to escape your single quotes... i.e. put a backslash in front of them

vientorio
12-27-2003, 05:20 PM
OK thanks, i got the script to stop throwing a n error, just now that it doesent open a popup window. i inserted the code like this

<?php

print("<html>
<head>
'<script type='text/javascript'>window.open(\'httpURL/assign.php?l=vientorio&mode=behind\');</script>';
<TITLE>Downloading...</TITLE>
<style type=\"text/css\">
<!--
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:hover {text-decoration: none;}
a:hover{color:red}
-->
</style>

</head>


have i missed somthing?

Rich2k
12-27-2003, 05:45 PM
Yes your code is a bit of a mess, you're mixing up HTML, Javascript and PHP.

You don't need to single quotes before or after <script... /script> or the semi-colon at the end of the line.

vientorio
12-27-2003, 07:00 PM
Yes i agree with this script being a little messey, i do not own it nor can i totally adjust it, as the server admin i have been authorized by the client to add the code nessesary to open a bop behind window

Thankyou for looking into this

Regards,
Geoff

vientorio
01-03-2004, 05:17 AM
Thankyou to all who aided me in solving this issue. it now works!

Cheers,
Geoff