开发者

Submitting a form to a new window using JavaScript - with Strict DocType

Ok, so here's my code for submitting the form:

document.开发者_运维技巧forms['formid'].submit();

The Form Target attribute is deprecated for the DocType I'm using -

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd

and I really don't want to use a different DocType as a work around for something so simple - so what are my options for submitting to a new window?


If you're talking about doing this from JavaScript (and the title of the question definitely makes it seem like you are), then you should be able to set the "target" attribute from your code. The W3C police won't arrest you, because your page will still validate. Once it's parsed into a DOM representation, the doctype is not very relevant (except in so far as it affects quirks mode etc).

document.forms['formid'].target = 'http://whatever.com';
document.forms['formid'].submit();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜