简体   繁体   English

使用不带src属性的iframe

[英]Use iframe without src attribute

In my web page, users can click on inputs which are check boxes. 在我的网页中,用户可以单击复选框的输入。 Later in their browsing, the options they chose cause other html documents to be displayed in the page they are in. At least that's the idea. 在稍后的浏览中,他们选择的选项导致其他html文档显示在它们所在的页面中。至少是这样。

So, User A clicks check boxes for "Doc1" and "Doc4". 因此,用户A单击“ Doc1”和“ Doc4”的复选框。 An ajax call goes out to a web service and pulls these documents back. 一个ajax调用转到Web服务,然后将这些文档拉回。 They are html. 它们是html。 The callback method should take this html and insert it into the page. 回调方法应使用此html并将其插入页面。

I tried using an iframe, however that seems to require the src attribute to be specified. 我尝试使用iframe,但是似乎需要指定src属性。 The html that comes back is a full page including . 返回的html是包含的完整页面。 This would be on an HTML5 compatible browser only. 这只能在兼容HTML5的浏览器上进行。

Is this possible, or should I be looking at something other than iframe? 这是否可能,或者我是否应该查看iframe以外的产品?

I solved this as follows: 我解决了如下问题:

  • User checks a couple check boxes and clicks 'next'. 用户选中几个复选框,然后单击“下一步”。
  • AJAX call goes out to retrieve those documents associated with the checkboxes. AJAX调用出去以检索与复选框关联的那些文档。
  • The page displaying retrieves this data, and creates iframes as needed. 显示的页面会检索此数据,并根据需要创建iframe。
  • SRC cannot be specified because there is NO url! 无法指定SRC,因为没有url!
  • IE doesn't support ...'> because 2083 chars is the limit for IE. IE不支持...'>因为2083个字符是IE的限制。
  • Final solution is to write manually to the iframe: 最终的解决方案是手动写入iframe:
 var target = document.getElementById(someIframe).contentDocument; target.open(); target.write(documentReceivedFromAJAXCall); target.close(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM