I want to achieve the same ... window.open('lalala.php', 'lalala', '...'); But I want to send a...">

Not obsolete equivalent <form target = "...">

I want to achieve the same ...

window.open('lalala.php', 'lalala', '...'); 

But I want to send an HTTP POST request instead of an HTTP GET request. So I use the following:

 $('<form/>').attr('action', 'lalala.php') .attr('target', 'lalala') // w3schools.org says this is deprecated .attr('method', 'post') .append(hiddenParam('param1', param1)) .append(hiddenParam('param2', param2)) .submit().remove(); // hiddenParam is a function I created that returns an input tag // the type attribute set to hidden, // the id attribute set to the first parameter, // and the value attribute set to the second parameter 

However, the target attribute is deprecated. Is there a way to achieve what I'm trying to do with non-obsolete means?

+6
dom html xhtml html-form forms
source share
3 answers
  • target absent only in strict doctrines. It is not out of date. The simplest solution is to use a transition type.
  • All browsers that I know of are doing the right thing, even if you use strict doctype.
  • If you must use strict doctype and you really care about checking it, you can extend the definition of doctype:

Just know this β€œerror” in just about every browser . The solution is to serve your XHTML as application/xhtml+xml , but this will cause IE to explode, so you need to sniff for this browser before determining the type of content. This is, in fact, one giant hack of a tiny check box in the form of verification. It is usually easier to just use a transitional doctype.

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" [ <!ATTLIST form target CDATA #IMPLIED> ]> 
+5
source share

Use target - it is not out of date.

+6
source share

Add

 <form target="lalala" ...></form> 
0
source share

All Articles