0

I would like to my script work after website refresh. I have JavaScript code that is injecting to webbrowser.

string element = "alert(\"hello\")";
 form1.webBrowser1.Document.InvokeScript("eval", new object[] { element });
Joshua Dannemann
  • 2,003
  • 1
  • 14
  • 34
xanon25
  • 9
  • 1

1 Answers1

0

Shamelessly stolen from here:

"You don't want the refresh, you want the onbeforeunload event.

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

Sample code from article"

<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>
Community
  • 1
  • 1
Xeper Caz
  • 48
  • 7