drz73366 2014-11-28 06:57
浏览 46
已采纳

window.open什么都不做

I'm trying to show some info in a pop-up window usig a window.open.. but when I click nothing happens.

This is the function that opens a new window.

function goNewWin(sell_code){

// Set height and width
var NewWinHeight=1000;
var NewWinWidth=1000;

// Place the window
var NewWinPutX=10;
var NewWinPutY=10;

//Get what is below onto one line

TheNewWin =window.open("renovations_history.php?sell_code=" + sell_code,
'Renovaciones','fullscreen=yes,toolbar=no,location=no,status=no,menubar=no,scrollbars=no');

//Get what is above onto one line

TheNewWin.resizeTo(NewWinHeight,NewWinWidth);
TheNewWin.moveTo(NewWinPutX,NewWinPutY);

}
</script>

Here's the HTML, with some PHP.

<form>
  <input type="button" value="Renovaciones" onClick="goNewWin(<?php echo $row['sell_code']; ?>)">
</form>

Nor it works with:

<a href="javascript:goNewWin(<?php echo $row['sell_code']; ?>)">Renovaciones</a>

It's 2:22 am and I can think straight, please help.

  • 写回答

2条回答 默认 最新

  • dongzhong8834 2014-11-28 07:02
    关注

    You need to add single quotes to the JavaScript function call:

    <?php
    $sell_code = $row['sell_code'];
    ?>
    <input type="button" value="Renovaciones" onClick="goNewWin('<?php echo $sell_code]; ?>')">
    

    Without it, Javascript will consider your $row['sell_code'] as a javascript keyword.

    You need to pass it as a string (function parameter).

    Reference

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化