Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript popwin在php中不工作_Javascript_Php_Popup - Fatal编程技术网

javascript popwin在php中不工作

javascript popwin在php中不工作,javascript,php,popup,Javascript,Php,Popup,我已经创建了一个小PHP脚本。见下文: $x=5; if ($x >= 8 ) { echo "x is ".$x; } else { echo 'error'; $errorWindow = 'www.google.com'; echo "<script type='text/javascript'> popWin('$errorWindow', 'windowname', 'width=400,height=300,scrollbar

我已经创建了一个小PHP脚本。见下文:

$x=5;
if ($x >= 8 ) {
   echo "x is ".$x;
} else {
   echo 'error';
   $errorWindow = 'www.google.com';
   echo "<script type='text/javascript'>
        popWin('$errorWindow', 'windowname', 'width=400,height=300,scrollbars=yes');
     </script>";    
}
$x=5;
如果($x>=8){
echo“x是”。$x;
}否则{
回声“错误”;
$errorWindow='www.google.com';
回声“
popWin(“$errorWindow”,“windowname”,“宽度=400,高度=300,滚动条=yes”);
";    
}
但我的popwin不工作,我想知道为什么,浏览器页面上打印了“错误”消息,但弹出窗口没有出现。谁能告诉我我做错了什么?我怎样才能得到popwin

编辑

我在语法上做了一些修改,下面是该页面的完整代码:

 $x=5;
    if ($x >= 8 ) {
       echo "x is ".$x;
    } else {
?><script type="text/javascript">
                        function popWin(url)
                        {
                            var thePopCode = window.open(url,'','height=800, width=1000, top=500, left=200, scrollable=yes, menubar=yes, resizable=yes');
                            if (window.focus) 
                            {
                                thePopCode.focus();
                            }
                        }
                    </script>
                <?php
                $errorWindow='google.com';
                echo "<script type='text/javascript'>
        popWin($errorWindow);
     </script>";    
            }
$x=5;
如果($x>=8){
echo“x是”。$x;
}否则{
?>
函数popWin(url)
{
var thePopCode=window.open(url,,'height=800,width=1000,top=500,left=200,scrollable=yes,menubar=yes,resizeable=yes');
if(window.focus)
{
phocode.focus();
}
}
这是有效的

<?php
$x=5;
if($x >= 8 ) {
       echo "x is ".$x;
    } else {
    echo "Error";
?><script type="text/javascript">
                        function popWin(url)
                        {
                            var thePopCode = window.open(url,'','height=800, width=1000, top=500, left=200, scrollable=yes, menubar=yes, resizable=yes');

                            if (window.focus) 
                            {
                                thePopCode.focus();
                            }
                        }
                    </script>
                <?php
                $errorWindow='google.com';
                echo "<script type='text/javascript'>
                popWin('google.com');
     </script>";    
            }
            ?>

函数popWin(url)
{
var thePopCode=window.open(url,,'height=800,width=1000,top=500,left=200,scrollable=yes,menubar=yes,resizeable=yes');
if(window.focus)
{
phocode.focus();
}
}
试试这个

<?php

 $x=5;
    if ($x >= 8 ) {
       echo "x is ".$x;
    } else {
?>
<script>
                        function popWin(url)
                        {
                            alert(url);
                            var thePopCode = window.open(url,'','height=800, width=1000, top=500, left=200, scrollable=yes, menubar=yes, resizable=yes');
                            if (window.focus) 
                            {
                                thePopCode.focus();
                            }
                        }
                    </script>
                <?php
                $errorWindow='http://www.google.com'; //with http://
                echo "<script type='text/javascript'>               
        popWin('$errorWindow'); //with single quotes
     </script>";    
            }

?>

函数popWin(url)
{
警报(url);
var thePopCode=window.open(url,,'height=800,width=1000,top=500,left=200,scrollable=yes,menubar=yes,resizeable=yes');
if(window.focus)
{
phocode.focus();
}
}

popWin()的定义在哪里?更新了我的问题,但仍然不起作用。你试过我在下面的答案中写的吗?试过了,但仍然没有。我在其他popWin中这样做,我点击按钮,可能无法在popWin中创建popWin?我也试过这个“$errorWindow='google.com';标题(“位置:$errorWindow”)在else下而不是javascript下,但它保持空白页。创建重定向而不是弹出窗口也不错。
<?php

 $x=5;
    if ($x >= 8 ) {
       echo "x is ".$x;
    } else {
?>
<script>
                        function popWin(url)
                        {
                            alert(url);
                            var thePopCode = window.open(url,'','height=800, width=1000, top=500, left=200, scrollable=yes, menubar=yes, resizable=yes');
                            if (window.focus) 
                            {
                                thePopCode.focus();
                            }
                        }
                    </script>
                <?php
                $errorWindow='http://www.google.com'; //with http://
                echo "<script type='text/javascript'>               
        popWin('$errorWindow'); //with single quotes
     </script>";    
            }

?>