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'; ?> 

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

        function popUpWindow(URLStr)   {
            if(popUpWin)   {
                if(!popUpWin.closed) popUpWin.close();
            popUpWin =;

        <script language="javascript">
            popUpWindow(<?php $URLString ?>);

Recommended Answers

All 2 Replies

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.

Thanks! That did it for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.