Javascript popup , html, php
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'];?>"/> <a href='#' onClick="javascript:开发者_开发问答return OpenWin();">Test</a> <input type="button" value="Test" onClick="return OpenWin();">
- the keyword
javascript:
is not necessary at attributeonClick
- 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'];?>"/>
<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'];?>"/> <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".
精彩评论