0

How do I call a PHP string from within javascript? This is parts of my code but it isn't working... Thanks!

<?php $URLString='MySite.html'; ?> 
<html> 
  <body> 

        <script language="JavaScript" type="text/JavaScript">
        var popUpWin=0;

        function popUpWindow(URLStr)   {
            if(popUpWin)   {
                if(!popUpWin.closed) popUpWin.close();
            }
            popUpWin = window.open(URLStr);
        }
        </script>    

        <script language="javascript">
            popUpWindow(<?php $URLString ?>);
        </script>    
  </body> 
</html> 
2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by RickL66
1

Change line 17:

popUpWindow(<?php echo "'$URLString'"; ?>);

This is not really referencing a PHP variable. PHP is merely outputting (injecting) the current value into the Javascript code.

Edited by pritaeas: Changed

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.