您好,登錄后才能下訂單哦!
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
(刪除按鈕),執行服務器操作clickdocument.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的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。