Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make that target="_blank" open always in the same window (not parent window)

I have a form with a target = _blank set up, which works as intended, but I am looking to make the submit form opens on the same window don't matter how munch submit I do. Does it make sense?, example:

Current behavior is:

  • "Parent window" has the form
  • When submit the first time a second window is opened, let called "Window Child 1" (until here is fine)
  • When I submit the form a second time another child window is loaded (I don't want this)

Behavior I need:

  • When I submit the form the second time I need to get the content on the same window that the first submit used "Window Child 1". Doing this I look to overwrite the result of the first submit with the second one on the same window.

I did this jsfiddle http://jsfiddle.net/5jmnk1rm/

<form action="/" method="post" id="form1" target="_blank">   
    <input type="submit" value="Submit" />        
</form>

Note: I should not use window.open (due other codes, etc...)

Update

I've changed the target="_blank" to target="customName" and it opens different windows in Chrome mobile (iOS). I am starting to think it is a bug on the browser

like image 824
Saymon Avatar asked Jan 08 '23 00:01

Saymon


1 Answers

All you need to do is replace _blank with a specific name.

<form action="/" method="post" id="form1" target="foo">   
    <input type="submit" value="Submit" />        
</form>

However you are in for some other complications like, the fact that some browser will open a new tab, instead of a window.

Additional Info

If you need to force opening in a new window regardless of how the user's browser is configured, you will have no choice but to use window.open. By setting the height and width options, you can force a window to open, not a tab.

like image 120
Jeffrey A. Gochin Avatar answered Jan 31 '23 06:01

Jeffrey A. Gochin