简体   繁体   English

Javascript弹出窗口,HTML,PHP

[英]Javascript popup , html, php

I want to open a pop up window onclick event of both button and link. 我想同时打开按钮和链接的弹出窗口onclick事件。 All is working fine but it opens a blank window when the page loads.I don't need it on loading , i just need the popup on click. 一切正常,但是页面加载时它会打开一个空白窗口。加载时不需要它,我只需要单击弹出窗口即可。 can anybody help me? 有谁能够帮助我? my code is below: 我的代码如下:

function OpenWin()
{
    window.open('../test.php','test','width=500,height=300,scrollbars=1');
return false;
}

the html for this is: 的HTML是这样的:

<input type="text" name="tst" value="<?php echo $editData['somefield'];?>"/>&nbsp;<a href='#' onClick="javascript:return OpenWin();">Test</a> <input type="button" value="Test" onClick="return OpenWin();">
  1. the keyword javascript: is not necessary at attribute onClick 关键字javascript:onClick属性上不是必需的
  2. Does the page test.php give any HTML code back to the browser? 页面test.php是否将任何HTML代码返回给浏览器? If not, no wonder why a blank page will be displayed. 如果不是,也难怪为什么会显示空白页。
<input type="text" name="tst" value="<?php echo $editData['somefield'];?>"/>&nbsp;
<a href="javascript:OpenWin();">Test</a> 
<input type="button" value="Test" onClick="OpenWin();">

对我来说很好用: http : //jsfiddle.net/2cPqa/1/

<script>function OpenWin()
{
    window.open('../test.php','test','width=500,height=300,scrollbars=1');
return false;
}</script>
<input type="text" name="tst" value="<?php echo $editData['somefield'];?>"/>&nbsp;<a href='#' onClick="OpenWin();">Test</a> <input type="button" value="Test" onClick="OpenWin();">

Example: http://codepad.viper-7.com/WlbTxw.php53 示例: http//codepad.viper-7.com/WlbTxw.php53

Should work, unless you use that script in <iframe> for some reason. 应该可以工作,除非出于某种原因在<iframe>使用该脚本。

Hint: There really shouldn't be "result". 提示:确实不应有“结果”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM