你如何发布到iframe?

编程入门 行业动态 更新时间:2024-10-27 09:48:25
本文介绍了你如何发布到iframe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何将数据发布到iframe?

How do you post data to an iframe?

推荐答案

取决于发布数据的含义。您可以在< form /> 标记上使用HTML target =属性,因此它可能是简单如下:

Depends what you mean by "post data". You can use the HTML target="" attribute on a <form /> tag, so it could be as simple as:

<form action="do_stuff.aspx" method="post" target="my_iframe"> <input type="submit" value="Do Stuff!" /> </form> <!-- when the form is submitted, the server response will appear in this iframe --> <iframe name="my_iframe" src="not_submitted_yet.aspx"></iframe>

如果不是,或者您需要更复杂的事情,请编辑您的问题以包含更多内容详细信息。

If that's not it, or you're after something more complex, please edit your question to include more detail.

Internet Explorer存在一个已知错误,只有在您使用Javascript动态创建iframe等时才会出现(有一个在这里解决方法),但如果你使用普通的HTML标记,你没事。目标属性和框架名称不是一些聪明的忍者黑客;虽然它在HTML 4 Strict或XHTML 1 Strict中已被弃用(因此不会验证),但它自3.2起就成为HTML的一部分,它正式成为HTML5的一部分,并且它自Netscape 3起几乎适用于所有浏览器。

There is a known bug with Internet Explorer that only occurs when you're dynamically creating your iframes, etc. using Javascript (there's a work-around here), but if you're using ordinary HTML markup, you're fine. The target attribute and frame names isn't some clever ninja hack; although it was deprecated (and therefore won't validate) in HTML 4 Strict or XHTML 1 Strict, it's been part of HTML since 3.2, it's formally part of HTML5, and it works in just about every browser since Netscape 3.

我已将此行为验证为使用XHTML 1 Strict,XHTML 1 Transitional,HTML 4 Strict以及未指定DOCTYPE的quirks模式,并且它适用于所有使用Internet的情况Explorer 7.0.5730.13。我的测试用例包含两个文件,在IIS 6上使用经典ASP;它们已在此完整复制,因此您可以自行验证此行为。

I have verified this behaviour as working with XHTML 1 Strict, XHTML 1 Transitional, HTML 4 Strict and in "quirks mode" with no DOCTYPE specified, and it works in all cases using Internet Explorer 7.0.5730.13. My test case consist of two files, using classic ASP on IIS 6; they're reproduced here in full so you can verify this behaviour for yourself.

default.asp

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "www.w3/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Form Iframe Demo</title> </head> <body> <form action="do_stuff.asp" method="post" target="my_frame"> <input type="text" name="someText" value="Some Text" /> <input type="submit" /> </form> <iframe name="my_frame" src="do_stuff.asp"> </iframe> </body> </html>

do_stuff.asp

<%@Language="JScript"%><?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "www.w3/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Form Iframe Demo</title> </head> <body> <% if (Request.Form.Count) { %> You typed: <%=Request.Form("someText").Item%> <% } else { %> (not submitted) <% } %> </body> </html>

我很想知道任何浏览器没有正确运行这些示例。

I would be very interested to hear of any browser that doesn't run these examples correctly.

更多推荐

你如何发布到iframe?

本文发布于:2023-10-11 17:48:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1482397.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:iframe

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!