为了将 HTML 表单重定向到严格 DTD 下的新选项卡,我应该做什么?
目标属性似乎不是严格 DTD 的一部分。我想这是因为框架已被弃用。但是如果我的目标不是另一个框架,而是一个新选项卡(target =“_blank”)怎么办?有没有办法做到这一点并仍然在严格的 DTD 下进行验证?在某些地方,人们建议使用 JavaScript“手动”打开新选项卡。这真的有必要吗? (另外,我具体询问的是表单,而不是简单的链接,这似乎更复杂。)
顺便说一句,我知道以前已经问过这个问题(例如这里 打开表单的正确方法是什么现在在新窗口中提交目标是已弃用),但我还没有找到好的答案。
It seems the target attribute is not a part of the strict DTD. I guess this is because frames are deprecated. But what if my target is not another frame, but a new tab (target="_blank")? Is there a way to do this and still validate under the strict DTD? In some places people recommend using JavaScript to "manually" open the new tab. Is this really necessary? (Plus I'm asking specifically about forms, not simple links, which seem to be more complicated.)
By the way, I know this has been asked before (for example here What is the correct way to open a form submit in a new window now target is deprecated), but I haven't found a good answer yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTML 5 中再次允许使用 target 属性,这是当今人们应该使用的 doctype。所有主流浏览器都有 HTML 5 解析器,即使您不使用任何其他 HTML 5 功能,目前至少更新 doctype 本身就足够了。
我还强烈建议您不要使用目标,因为当用户可能不想这样做时,这会强制浏览器打开新窗口/选项卡。让他们自己决定如何打开链接。
由于您的帖子也被标记为 XHTML 1.0 Strict,因此我邀请您阅读这些链接,它们解释了为什么 XHTML 不是必需的:
The target attribute is allowed again in HTML 5, which is the doctype one should be using these days. All major browsers have HTML 5 parsers, and at least updating the doctype itself is enough for now, even if you don't use any other HTML 5 features.
I would also strongly recommend you NOT use target, because that forces a browser to open a new window/tab when the user might not want to do that. Let them make their own decision on how to open a link instead.
Since your post was also tagged as XHTML 1.0 Strict, I invite you to read these links which explain why XHTML isn't necessary: