0

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();">
Zirak
40k13 gold badges85 silver badges92 bronze badges
asked May 6, 2011 at 12:35
3
  • Please, post more from your html code. Commented May 6, 2011 at 12:38
  • nothing else for this pop up. only the given html is Commented May 6, 2011 at 12:42
  • please click the checkbox if one of these answers was helpful. Commented Jun 13, 2011 at 1:16

4 Answers 4

1
  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.
Peter Lawrey
535k83 gold badges770 silver badges1.2k bronze badges
answered May 6, 2011 at 12:50
Sign up to request clarification or add additional context in comments.

1 Comment

I agree with GlitchMr answer. All things looks fine. Because we cannot see your complete code, I think there must be something wrong with your php page.
0
<input type="text" name="tst" value="<?php echo $editData['somefield'];?>"/>&nbsp;
<a href="javascript:OpenWin();">Test</a> 
<input type="button" value="Test" onClick="OpenWin();">
answered May 6, 2011 at 12:47

Comments

0

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

answered May 6, 2011 at 12:48

2 Comments

add this function to your javascript, function open() { } Now it will not work. what's the problem?
<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();">
0
<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".

answered May 6, 2011 at 12:48

2 Comments

not working.actually on my page there is a another javascript function
function(){} this doesn't allow the popup to display, when i comment it, and refresh the page, first a blank window popsup and then onclick it works. i don't need that blank window on load

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.