开发者

Window.Open() incorrectly escaped?

I'm a relatively light JavaScript user, so this minor operation is giving me some major grief -- I'm sure I'm missing something.

All I want is a popup to open, passing one value -- the emplogin, a开发者_JAVA技巧 string variable called getEmp -- to a bog-standard .php page thusly:

<script type="text/javascript">
function getEmployeeInfo(getEmp)
{
window.open ("../Pages/Employee_Info.php?emplogin=" + getEmp + ",\"mywin\",\"menubar=0,resizable=1,scrollbars=1,width=600,height=450\"");
}
</script>

And it works... sort of. Testing the result by looking at the resulting $_REQUEST object shows me that the page is receiving the $emplogin as

Array
(
    [emplogin] =>JohnDoe,"mywin","menubar=0,resizable=1,scrollbars=1,width=600,height=450"
)

IOW, the second and third parameters for Window.Open() are being passed along as part of the $emplogin received by PHP, instead of being parsed by JavaScript! (I'm using 'echo htmlspecialchars(print_r($_REQUEST, true));')

I'm sure there's something I'm not doing right with the escaping of the parameters but I haven't been able to hit on the right search terms. Thank you for any and all guidance!


Try this:

<script type="text/javascript">
function getEmployeeInfo(getEmp)
{
    window.open ("../Pages/Employee_Info.php?emplogin=" + getEmp, "mywin", "menubar=0,resizable=1,scrollbars=1,width=600,height=450");
}
</script>


You're including your second and third parameters as part of your URL string, so it's all being treated as one single parameter.

What you want is: window.open ("../Pages/Employee_Info.php?emplogin=" + getEmp,"mywin","menubar=0,resizable=1,scrollbars=1,width=600,height=450");


That is how it should be:

<script type="text/javascript">
function getEmployeeInfo(getEmp)
{
window.open ("../Pages/Employee_Info.php?emplogin=" + getEmp + ,"mywin","menubar=0,resizable=1,scrollbars=1,width=600,height=450");
}
</script>


urlencode your variable and remove the escaping of your other parameters in the open command

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜