[英]problem of getting url of loading html page (c#)
出色地,
我開發了一個本機瀏覽器,但在此瀏覽器上導航的站點出現問題。
輸入["type"] 按鈕單擊發布 http 請求以獲取並在新選項卡 (onglet) 中顯示其他頁面。
我正在嘗試幾種方法,但 TabPageof webBrowser 是空白的,我有一個 IE 瀏覽器 window 打開。
這里的代碼
private void Browser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
webBrowser22 = (WebBrowser)sender;
if (webBrowser22.Document != null)
{
foreach (HtmlElement tag in webBrowser22.Document.All)
{
HtmlElementCollection elements = webBrowser22.Document.GetElementsByTagName("input");
for (int i = 0; i < elements.Count; i++)
{
HtmlElement el = elements[i];
string elType = el.GetAttribute("type");
switch (elType)
{
case "radio":
case "checkbox":
case "button":
{
el.MouseUp += new HtmlElementEventHandler(link_MouseUpPup);
}
}}}}
private void link_MouseUpPup(object sender, HtmlElementEventArgs e)
{
this.tb2 = new System.Windows.Forms.TabPage();
this.webBrowser221 = new System.Windows.Forms.WebBrowser();
var linky = (HtmlElement)sender;
mshtml.HTMLAnchorElement ba = (mshtml.HTMLAnchorElement)linky.DomElement;
// if ((ba.target != null && ba.target.ToLower() == "_blank") || e.ShiftKeyPressed || e.MouseButtonsPressed == MouseButtons.Middle)
//if (Regex.Match(e.ReturnValue.ToString(), "http:").Value != null || Regex.Match(e.ReturnValue.ToString(), "https:").Value != null)
tabControl1.Controls.AddRange(new Control[] { this.tb2 });
tb2.Controls.AddRange(new Control[] { this.webBrowser221 });
webBrowser221.Dock = DockStyle.Fill;
1ERE METHODE----
//webBrowser221.Navigate(HttpContext.Current.Request.Url.AbsoluteUri);
2EME METHODE----
//webBrowser221.Navigate(ba.href);
3EME METHODE----
// webBrowser221.Navigate(HttpContext.Current.Request.ServerVariables["URL"].ToString());
4EME METHODE----
// webBrowser221.Navigate(e.ToElement.GetAttribute("onclick").ToString());
tb2.Text = e.ToElement.GetAttribute("onclick").ToString();
tb2.ToolTipText = webBrowser221.StatusText;
}
The problem is that I would opening the site page loading by the click input after his process (the process is been programmed in html and javascript with the function window.open and the property target="_blank") by the c# control webBrowser.
誰是問題所在,即打開的是瀏覽器而不是webBrowser window。
謝謝你的幫助。
嘛
最后,
I used the package reference "SHDocVm" of "Microsoft Internet Controls" and I place a function handler NewWindow3 after the case button and it's ok, a window.open() javascript function with target="_blank" opens a new page of webBrowser.
肅然。
嘛
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.