Reputation: 1
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();">
Upvotes: 0
Views: 1821
Reputation: 3948
javascript:
is not necessary at attribute onClick
test.php
give any HTML code back to the browser? If not, no wonder why a blank page will be displayed.Upvotes: 1
Reputation: 11879
<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".
Upvotes: 0
Reputation: 36671
<input type="text" name="tst" value="<?php echo $editData['somefield'];?>"/>
<a href="javascript:OpenWin();">Test</a>
<input type="button" value="Test" onClick="OpenWin();">
Upvotes: 0