1

好吧,标题说明了一切,我有一个主屏幕,用户可以在其中看到一些数据,然后他们可以单击一个按钮,使用window.open.

但是在弹出窗口中,我想显示在主屏幕上定义的一些变量以及在弹出屏幕中计算的其他一些变量。

我尝试使用$_SESSION,但由于某种原因不起作用..如果有人知道如何使用 JavaScript 或 PHP 将变量从主屏幕“传递”到弹出屏幕/文件?

HTML:

<input type="button" value="Klik hier om uw terugverdientijd te berekenen" id="btnTerugverdientijd" onclick="basicPopup('/wp-content/themes/blackbird/phpwizard/HTML5Application/public_html/terugVerdientijd.php')" />

JavaScript:

function basicPopup(url) 
{
    popupWindow = window.open(url,'popUpWindow','height=500,width=500,left=1400,top=300,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');
}

谢谢你的时间!

4

4 回答 4

0

我会通过查询字符串传递值,例如 terugVerdientijd.php?name1=value&name2=value2

这使得编码更简单。

于 2013-04-23T09:59:06.757 回答
0

Try with get method like

function basicPopup(url) 
{
    url = url + '?id=1221';
    popupWindow = window.open(url,'popUpWindow','height=500,width=500,left=1400,top=300,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');
}

and at your popup you try with

echo $_GET['id'];

thats it...

于 2013-04-23T09:57:26.867 回答
0

使用 javascript/jQuery,您可以将变量附加到您的 url,然后在服务器端处理它们并显示在弹出窗口中。

于 2013-04-23T09:57:41.013 回答
0
        Java Script 
        <script>
            function Popup(url) {
                var width = 700;
                var height = 500;
                var left = (screen.width - width) / 2;
                var top = (screen.height - height) / 2;
                var params = 'width=' + width + ', height=' + height;
                params += ', top=' + top + ', left=' + left;
                params += ', directories=no';
                params += ', location=no';
                params += ', menubar=no';
                params += ', resizable=yes';
                params += ', scrollbars=yes';
                params += ', status=no';
                params += ', toolbar=no';
                newwin = window.open(url, '_blank', params);
                //newwin = window.showModalDialog(url, 'popup', params);
                if (window.focus) { newwin.focus() }
                return false;
            }

        </script>
    //in any Button Event in your CS file Add



     protected void Raisepopup(object sender, EventArgs e)
        {
            string Chaubey = "123";
            string Rakesh = "../QueryString?Chaubey=" + Chaubey ;
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "temp", "<script type='text/javascript'>Popup('" + Rakesh + "');</script>", false);
        }


//Kindly reply if it resolves the Issue. 
于 2013-04-23T10:11:19.117 回答