开发者

Javascript popup , html, php

开发者 https://www.devze.com 2023-03-03 23:02 出处:网络
I want to open a pop up window onclick event of both button and link. 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.

I want to open a pop up window onclick event of both button and link. 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:

<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
  2. Does the page test.php give any HTML code back to the browser? 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();">


Works fine for me: 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

Should work, unless you use that script in <iframe> for some reason.

Hint: There really shouldn't be "result".

0

精彩评论

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