2015-10-27 68 views
0

我想我的腳本在網站刷新後工作。我有注入到瀏覽器的JavaScript代碼。刷新後注入JavaScript

string element = "alert(\"hello\")"; 
 
form1.webBrowser1.Document.InvokeScript("eval", new object[] { element });

回答

0

無恥地從here被盜:

「你不想刷新,你想onbeforeunload事件從文章

http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx

示例代碼。 「

<HTML> 
<head> 
<script> 
function closeIt() 
{ 
    return "Any string value here forces a dialog box to \n" + 
     "appear before closing the window."; 
} 
window.onbeforeunload = closeIt; 
</script> 
</head> 
<body> 
    <a href="http://www.microsoft.com">Click here to navigate to 
     www.microsoft.com</a> 
</body> 
</html>