刚刚完成的一个应用用到了iframe,稍做记录如下以备忘。
      需求(程序员角度):
      1,商品查询页面(AppItemSearch.aspx)发送了这样一个请求:AppItemIntroduction.aspx?ItemId=xxx
      2,商品介绍页面(AppItemIntroduction.aspx)根据ItemId "xxx"从数据库中ItemIntroductionLinks表中查询对应xxx的商品介绍文档的链接(ItemIntroLink字段),并将此连接的内容显示到AppItemIntroduction.aspx页面上。
      注:AppItemIntroduction.aspx根据ItemId读取的不是商品介绍的内容而仅仅是一个链接名称;商品介绍文档放在与此应用不同域的服务器上;商品介绍文档是html或word文档。
      假设:AppItemIntroduction.aspx已经根据ItemId在ItemIntroductionLinks中找到了对应的文档url,存于ls_RedURL变量里。
      思路:在AppItemIntroduction.aspx里生成一个iframe标志,变量ls_RedURL的值动态赋给iframe的src属性。
      简单源码(vb.net)如下:
iframe应用-后台生成iframe标记        jsText = "<script>var child=document.getElementById('ifr1');if(child!=null){document.body.removeChild(child);}</script>"
iframe应用-后台生成iframe标记        jsText 
+= "<iframe id='ifr1' width=90% height=90% src='" + ls_RedURL + "'></iframe>"
iframe应用-后台生成iframe标记        jsText 
+= "<div align='center'><a href='#' onclick='javascript:window.close()'>关-闭</a></div>"
iframe应用-后台生成iframe标记        
Try
iframe应用-后台生成iframe标记            Response.Write(jsText)
iframe应用-后台生成iframe标记        
Catch ex As Exception
iframe应用-后台生成iframe标记            ls_ErrText 
= ex.Message + "读取产品介绍文档出错!"
iframe应用-后台生成iframe标记            AppGoToErrorPage.f_Redirect(
Me, ll_ErrCode, ls_ErrText, "C")
iframe应用-后台生成iframe标记        
End Try

相关文章:

  • 2021-11-23
  • 2021-07-17
  • 2021-11-19
  • 2021-09-15
  • 2021-06-11
  • 2021-06-28
  • 2021-07-07
  • 2021-07-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-06-02
  • 2021-11-03
相关资源
相似解决方案