Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

Opening a page in the same window with a form submit

window.open, _self, submit

10:58 am on Feb 17, 2009 (gmt 0)

New User

5+ Year Member

joined:Feb 11, 2009
posts: 8
votes: 0


Is there a way I can open a page in the current window when I do a form submit?

Here is my code.
<form name="airForm" id="airForm" onsubmit=fun()>
<input type="submit" value="Submit">
<script language="javascript">
function fun(){
window.open("http://google.com", "_self");

It works fine if I change the 'submit' to a 'button'.

<form name="airForm" id="airForm" >
<input type="button" value="Submit" onClick=fun()>

Thanks for any help.

[edited by: Gopinath at 11:04 am (utc) on Feb. 17, 2009]

1:36 pm on Feb 17, 2009 (gmt 0)


WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
votes: 0

Welcome to WebmasterWorld, Gopinath.

A form submit stays in the same window. No need to be using JavaScript.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members