如何在IE中打開一個網頁,同時點擊c#應用程序中的一個按鈕。 我的意圖是創建一個c#應用程序的web登錄,它需要在IE中以指定的寬度和高度打開,並且需要在應用程序中調用一個函數。在IE中使用c打開一個網頁#
回答
從http://msdn.microsoft.com/en-us/library/system.diagnostics.process(VS.71).aspx
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
public class MyProcess
{
/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
public void OpenApplication(string myFavoritesPath)
{
// Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe");
// Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath);
}
/// <summary>
/// Opens urls and .html documents using Internet Explorer.
/// </summary>
public void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}
/// <summary>
/// Uses the ProcessStartInfo class to start new processes, both in a minimized
/// mode.
/// </summary>
public void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
public static void Main()
{
// Get the path that stores favorite links.
string myFavoritesPath =
Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
MyProcess myProcess = new MyProcess();
myProcess.OpenApplication(myFavoritesPath);
myProcess.OpenWithArguments();
myProcess.OpenWithStartInfo();
}
}
}
謝謝你Tzury,但我已經更新了所有我需要的問題plz看一看吧 – raki 2009-09-16 05:36:22
我知道你的C#代碼與客戶端的DOM交互的唯一方法是將IE作爲控制器嵌入到WinForm中。否則,你可以編寫自己的IE加載項來完成這個任務如果你只想調用一個JavaScript函數,你可以使用我在下面建議的選項(作爲答案)並在URL中使用一個參數來實現 - Tzury 3分鐘前[刪除此評論] – 2009-09-16 05:57:31
System.Diagnostics.Process.Start("iexplore", "http://example.com");
有一個在默認瀏覽器打開一個網頁System.Diagnostics.Process.Start(url);
如果你想特別是在IE中打開它,你可能需要創建一個新的IE的方式以URL作爲參數處理。
UPD:(即http://stackoverflow.com/page?runFunction=1
)如果你想運行功能,插入GET參數到您的URL字符串,並在runFunction參數應用程序代碼檢查,並根據其值決定,如果你的應用程序需要運行功能。
我不認爲可以指定新的IE窗口寬度和高度值,您可能需要使用JavaScript。
這是正確答案:System.Diagnostics.Process.Start(url),使用默認瀏覽器並避免許多與系統,安裝和定製相關的其他因素。 – 2013-12-06 14:24:21
- 1. 使用閃光燈在瀏覽器中打開一個網頁
- 2. 在IE中打開一個tiff圖像
- 3. 打開在IE網址的陣列,IE是否打開或不使用的PowerShell
- 4. 如何在標籤中打開新的網頁在C#中的IE 8
- 5. 打開一個網頁,然後下載一個文件C#
- 6. C#如何打開一個網頁並點擊一個按鈕
- 7. 如何在網頁中打開網頁?
- 8. 在網頁中打開網頁
- 9. 在現有網頁中打開網頁
- 10. 在Firefox中打開網頁
- 11. 網站只在IE中打開
- 12. 使網頁在一段時間後自動打開另一個網頁?
- 13. 目標C,打開一個網站,而不打開它在Safari
- 14. Cortana App打開一個網頁
- 15. 打開網頁
- 16. 如何使用mvc3剃鬚刀打開一個新的網頁
- 17. 從網頁在finder/explorer中打開一個文件夾?
- 18. 檢測IE在PHP然後打開網頁
- 19. 如何在打開特定網頁時分析IE活動
- 20. 在IE中使用selenium-webdriver在新選項卡中打開一個URL
- 21. 在app cordova打開網頁
- 22. 使用搜索引擎打開網頁
- 23. 強制使用Internet Explorer打開網頁
- 24. 使用perl打開和關閉網頁
- 25. 無法使用UIWebView打開網頁
- 26. 網頁在IE
- 27. 一旦Webbrowser1更改頁面,立即打開一個網頁?
- 28. 使用javascript在網頁上打開多個鏈接
- 29. 打開網頁onclick
- 30. 網頁未打開
Web應用程序中的JavaScript函數中的函數? – 2009-09-16 05:41:54
我知道讓C#代碼與* client *端的DOM交互的唯一方法是將IE作爲控制器嵌入到WinForm中。 否則,你可以編寫你的IE加載項,它會爲你做這個 如果你只想調用一個JavaScript函數,你可以使用我在下面建議的選項(作爲答案),並使用URL中的參數來這樣做 – 2009-09-16 05:53:31
如果你想做某種遠程認證,你肯定需要一個Web服務?你提出的建議似乎有點不尋常(不是我想阻止你調查不尋常的事情)。 – Xiaofu 2009-09-16 05:57:36