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();">
Zirak
40k13 gold badges85 silver badges92 bronze badges
-
Please, post more from your html code.Reporter– Reporter2011年05月06日 12:38:43 +00:00Commented May 6, 2011 at 12:38
-
nothing else for this pop up. only the given html isuser321038– user3210382011年05月06日 12:42:22 +00:00Commented May 6, 2011 at 12:42
-
please click the checkbox if one of these answers was helpful.two7s_clash– two7s_clash2011年06月13日 01:16:36 +00:00Commented Jun 13, 2011 at 1:16
4 Answers 4
- the keyword
javascript:is not necessary at attributeonClick - Does the page
test.phpgive 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
Reporter
3,9345 gold badges36 silver badges50 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Reporter
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.
<input type="text" name="tst" value="<?php echo $editData['somefield'];?>"/>
<a href="javascript:OpenWin();">Test</a>
<input type="button" value="Test" onClick="OpenWin();">
answered May 6, 2011 at 12:47
Vishwanath Dalvi
36.9k41 gold badges128 silver badges156 bronze badges
Comments
Works fine for me: http://jsfiddle.net/2cPqa/1/
answered May 6, 2011 at 12:48
two7s_clash
5,8451 gold badge31 silver badges45 bronze badges
2 Comments
user321038
add this function to your javascript, function open() { } Now it will not work. what's the problem?
user321038
<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();">
<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".
answered May 6, 2011 at 12:48
null
12k3 gold badges60 silver badges74 bronze badges
2 Comments
user321038
not working.actually on my page there is a another javascript function
user321038
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
default