user321038
user321038

Reputation: 1

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'];?>"/>&nbsp;<a href='#' onClick="javascript:return OpenWin();">Test</a> <input type="button" value="Test" onClick="return OpenWin();">

Upvotes: 0

Views: 1821

Answers (4)

Reporter
Reporter

Reputation: 3948

  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.

Upvotes: 1

null
null

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'];?>"/>&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".

Upvotes: 0

two7s_clash
two7s_clash

Reputation: 5827

Works fine for me: http://jsfiddle.net/2cPqa/1/

Upvotes: 0

Vishwanath Dalvi
Vishwanath Dalvi

Reputation: 36671

<input type="text" name="tst" value="<?php echo $editData['somefield'];?>"/>&nbsp;
<a href="javascript:OpenWin();">Test</a> 
<input type="button" value="Test" onClick="OpenWin();">

Upvotes: 0

Related Questions