p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: using Javascript window.open in php


Message #1 by "Jamal" <new_mojam@y...> on Sat, 5 Oct 2002 10:45:59
Hi,
why is my code not working?? Please anyone with an idea. Here is my code.
this is index.html
<html> 
<head> 
<script language="javascript"> 
function openthing(url) 
{ 
window.open(""+url+"","windowname","width=280,height=150, 
screenX=340,left=340,screenY=180,top=180,resizable=no, 
toolbar=no,status=no,menubar=no,scrollbars=no"); 
} 
</script> 
</head> 
<body> 
<a href="javascript:openthing('popup.php?link=1')">Link 1</a> 
<a href="javascript:openthing('popup.php?link=2')">Link 2</a> 
<a href="javascript:openthing('popup.php?link=3')">Link 3</a> 
<a href="javascript:openthing('popup.php?link=4')">Link 4</a> 
</body> 
</html> 


this is popup.php

<?  
/* "$QUERY_STRING" is the number after the question 
mark in the links above */ 
$QUERY_STRING = $link; 
?> 

<html> 
<head> 
</head> 
<body> 

<? 
if ($link == "1")  
    {print ("Information for Link number one");} 
elseif ($link == "2")  
    {print ("Information for Link number two");} 
elseif ($link == "3")  
    {print ("Information for Link number three");} 
elseif ($link == "4")  
    {print ("Information for Link number four");} 
else 
    {print ("Sorry, you did not pass a query value");} 
?> 

<p> 
<? if ($link == "1") {print ("");}  
   else {print ("<b>&laquo;</b>");}?>  
    
   <a href="popup.php?link=<? print ($link-1); ?>"> 
<? if ($link == "1") {print ("");}  
   else {print ("Previous Link");}?> 
   </a> 
    
   <b>&#149;</b> 
   <a href="Javascript://" onClick="window.close();">Close 
window</a>         
   <b>&#149;</b> 
    
   <a href="popup.php?link=<? print ($link+1); ?>"> 
<? if ($link == "4") {print ("");}  
   else {print ("Next Link");}?> 
   </a> 

<? if ($link == "4") {print ("");}  
   else {print ("<b>&raquo;</b>");}?> 
</p> 

</body> 
</html> 
the index.html is supposed to do the link but it is not doing it. Please 
anyone to tell me why?? Or this might be better in the client side rather 
than server-side??
thanks in advance
Mo jam
Message #2 by "jorge" <jorge@d...> on Sat, 5 Oct 2002 08:31:29 -0500
You got extra "" in
window.open(""+url"",....

Saludos

Jorge Cordero
----- Original Message -----
From: "Jamal" <new_mojam@y...>
To: "beginning php" <beginning_php@p...>
Sent: Saturday, October 05, 2002 10:45 AM
Subject: [beginning_php] using Javascript window.open in php


> Hi,
> why is my code not working?? Please anyone with an idea. Here is my code.
> this is index.html
> <html>
> <head>
> <script language="javascript">
> function openthing(url)
> {
> window.open(""+url+"","windowname","width=280,height=150,
> screenX=340,left=340,screenY=180,top=180,resizable=no,
> toolbar=no,status=no,menubar=no,scrollbars=no");
> }
> </script>
> </head>
> <body>
> <a href="javascript:openthing('popup.php?link=1')">Link 1</a>
> <a href="javascript:openthing('popup.php?link=2')">Link 2</a>
> <a href="javascript:openthing('popup.php?link=3')">Link 3</a>
> <a href="javascript:openthing('popup.php?link=4')">Link 4</a>
> </body>
> </html>
>
>
> this is popup.php
>
> <?
> /* "$QUERY_STRING" is the number after the question
> mark in the links above */
> $QUERY_STRING = $link;
> ?>
>
> <html>
> <head>
> </head>
> <body>
>
> <?
> if ($link == "1")
>     {print ("Information for Link number one");}
> elseif ($link == "2")
>     {print ("Information for Link number two");}
> elseif ($link == "3")
>     {print ("Information for Link number three");}
> elseif ($link == "4")
>     {print ("Information for Link number four");}
> else
>     {print ("Sorry, you did not pass a query value");}
> ?>
>
> <p>
> <? if ($link == "1") {print ("");}
>    else {print ("<b>&laquo;</b>");}?>
>
>    <a href="popup.php?link=<? print ($link-1); ?>">
> <? if ($link == "1") {print ("");}
>    else {print ("Previous Link");}?>
>    </a>
>
>    <b>&#149;</b>
>    <a href="Javascript://" onClick="window.close();">Close
> window</a>
>    <b>&#149;</b>
>
>    <a href="popup.php?link=<? print ($link+1); ?>">
> <? if ($link == "4") {print ("");}
>    else {print ("Next Link");}?>
>    </a>
>
> <? if ($link == "4") {print ("");}
>    else {print ("<b>&raquo;</b>");}?>
> </p>
>
> </body>
> </html>
> the index.html is supposed to do the link but it is not doing it. Please
> anyone to tell me why?? Or this might be better in the client side rather
> than server-side??
> thanks in advance
> Mo jam


Message #3 by "jorge" <jorge@d...> on Sat, 5 Oct 2002 19:37:29 -0500
Jamal as i told you before you have an error ihn window open double ""
(""+url+""
a better way to call the function is to use the Java Script event "onCLick"
like this
<a href="#" onClick="openthing('popup.php?link=1')">Link 1</a>
also bring the new wondow in focus windowname.focus();

<script language="javascript">
> function openthing(url)
> {
> window.open("url","windowname","width=280,height=150,
> screenX=340,left=340,screenY=180,top=180,resizable=no,
> toolbar=no,status=no,menubar=no,scrollbars=no");
windowname.focus();
> }
> </script>

Jorge Cordero
Saludos

----- Original Message -----
From: "Jamal" <new_mojam@y...>
To: "beginning php" <beginning_php@p...>
Sent: Saturday, October 05, 2002 10:45 AM
Subject: [beginning_php] using Javascript window.open in php


> Hi,
> why is my code not working?? Please anyone with an idea. Here is my code.
> this is index.html
> <html>
> <head>
> <script language="javascript">
> function openthing(url)
> {
> window.open(""+url+"","windowname","width=280,height=150,
> screenX=340,left=340,screenY=180,top=180,resizable=no,
> toolbar=no,status=no,menubar=no,scrollbars=no");
> }
> </script>
> </head>
> <body>
> <a href="javascript:openthing('popup.php?link=1')">Link 1</a>
> <a href="javascript:openthing('popup.php?link=2')">Link 2</a>
> <a href="javascript:openthing('popup.php?link=3')">Link 3</a>
> <a href="javascript:openthing('popup.php?link=4')">Link 4</a>
> </body>
> </html>
>
>
> this is popup.php
>
> <?
> /* "$QUERY_STRING" is the number after the question
> mark in the links above */
> $QUERY_STRING = $link;
> ?>
>
> <html>
> <head>
> </head>
> <body>
>
> <?
> if ($link == "1")
>     {print ("Information for Link number one");}
> elseif ($link == "2")
>     {print ("Information for Link number two");}
> elseif ($link == "3")
>     {print ("Information for Link number three");}
> elseif ($link == "4")
>     {print ("Information for Link number four");}
> else
>     {print ("Sorry, you did not pass a query value");}
> ?>
>
> <p>
> <? if ($link == "1") {print ("");}
>    else {print ("<b>&laquo;</b>");}?>
>
>    <a href="popup.php?link=<? print ($link-1); ?>">
> <? if ($link == "1") {print ("");}
>    else {print ("Previous Link");}?>
>    </a>
>
>    <b>&#149;</b>
>    <a href="Javascript://" onClick="window.close();">Close
> window</a>
>    <b>&#149;</b>
>
>    <a href="popup.php?link=<? print ($link+1); ?>">
> <? if ($link == "4") {print ("");}
>    else {print ("Next Link");}?>
>    </a>
>
> <? if ($link == "4") {print ("");}
>    else {print ("<b>&raquo;</b>");}?>
> </p>
>
> </body>
> </html>
> the index.html is supposed to do the link but it is not doing it. Please
> anyone to tell me why?? Or this might be better in the client side rather
> than server-side??
> thanks in advance
> Mo jam



  Return to Index