VB.NET中怎么访问Iframe
VB.NET中怎么访问Iframe,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
VB.NET访问Iframe前台页面:
< %@ Page Language="VB" AutoEventWireup="false"
CodeFile="mailindex.aspx.vb" Inherits="mailindex" %>
< %@ Register Assembly="Microsoft.Web.UI.WebControls,
Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="Microsoft.Web.UI.WebControls" TagPrefix="iewc" %>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//
EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server">
< title>供應商郵件管理< /title>
< link href ="body.css" rel ="Stylesheet" type ="text/css" />
< script language ="javascript" type ="text/javascript" >
触发iframe中删除按钮的事件
function get_delbt()
{
var info=window.confirm('確定要刪除該郵件嗎?');
if (info==true)
{
//这句很关键,通过找到mainframe,运用dom访问其中的控件btdel
(删除按钮),执行服务器操作click
document.getElementById("mainframe").contentWindow.document.
getElementById("btdel").click();
}
}
触发iframe中清空按钮的事件
function get_delallbt()
{
var info=window.confirm('確定要清空該郵件夾嗎?');
if (info==true)
{
document.getElementById("mainframe").contentWindow.document.
getElementById("btalldel").click();
}
}
< /script>
< /head>
< body>
< form id="form1" runat="server">
< !--#include virtual="head.inc"-->
< div align ="center" >
< table width ="750px" background="images/back.gif">
< thead >
< tr>
< th colspan ="5" align ="left" >
< iewc:Toolbar ID="Toolbar1" Width ="400px"
DefaultStyle ="background-image:url(images/BackgroundT.bmp)"
ToolTip ="工具欄" OnButtonClick ="toolbarbt_click" runat="server">
< iewc:ToolbarButton ID="inputbt"
ImageUrl="TreeLineImages/inbox.bmp" Text ="接收郵件"/>
< iewc:ToolbarButton ID="newbt"
ImageUrl="TreeLineImages/unreader.bmp" Text ="撰寫郵件" />
< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="delbt"
ImageUrl="TreeLineImages/unout.bmp" Text= "刪除郵件" />
< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="clearbt"
ImageUrl="TreeLineImages/reback.bmp" Text ="清空郵件" />
< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="infobt"
ImageUrl="TreeLineImages/hold.bmp" Text= "信息統計" />
< iewc:ToolbarSeparator />
< iewc:ToolbarButton ID="addressbt"
ImageUrl="TreeLineImages/mailbox.bmp" Text ="地址薄" />
< /iewc:Toolbar>
< /th>
< /tr>
< /thead>
< tbody >
< tr>
< td colspan="4" valign ="top" rowspan="2">
< iframe id="mainframe" name ="mainframe" runat ="server"
scrolling="auto" width ="600px" height ="400px" >< /iframe>
< /td>
< /tr>
< tr>
< /tr>
< /tbody>
< tfoot >
< tr>
< /tr>
< /tfoot>
< /table>
< /div>
< input id="delbt1" type="button" runat ="server" value="delete" />
< input id="clearbt1" type="button" runat ="server" value="clear" />
< /form>
< /body>
< /html>
Sub toolbarbt_click(ByVal sender As Object, ByVal e As EventArgs)
Select Case sender.id.ToString
Case "inputbt"
inputmail()
Return
Case "newbt"
Response.Write("< script>javascript:window.showModelessDialog
('sendmail.aspx',window,'dialogWidth:800px;resizable:yes;');
< /script>")
Return
Case "delbt"
Me.delbt1_ServerClick(delbt1, New EventArgs) '触发delbt1的click事件
Case "clearbt"
Me.clearbt1_ServerClick(clearbt1, New EventArgs)
'触发clearbt1的click事件,下面红色部分
Case "infobt"
Response.Write("< script>javascript:window.showModelessDialog
('mailinfo.aspx',window,'dialogWidth:800px;resizable:yes;');
< /script>")
Return
Case "addressbt"
Response.Write("< script>javascript:window.showModelessDialog
('mailbook.aspx',window,'dialogWidth:800px;resizable:yes;');
< /script>")
Return
Case Else
Response.Write("請選擇按鈕")
End Select
End Sub
Protected Sub delbt1_ServerClick(ByVal sender As Object,
ByVal e As System.EventArgs) Handles delbt1.ServerClick
'调用JS方法:get_delbt().执行iframe中删除按钮的事件!
Page.ClientScript.RegisterStartupScript(GetType(String), "",
"< script>javascript:get_delbt();< /script")
End Sub
Protected Sub clearbt1_ServerClick(ByVal sender As Object,
ByVal e As System.EventArgs) Handles clearbt1.ServerClick
'调用JS方法:get_delallbt().执行iframe中清空按钮的事件!
Page.ClientScript.RegisterStartupScript(GetType(String), "",
"< script>javascript:get_delallbt();< /script")
End Sub
看完上述内容,你们掌握VB.NET中怎么访问Iframe的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注编程网行业资讯频道,感谢各位的阅读!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341