Hi
I am having a seriou issue reagarding running a window.external.close() from a .NET webbrowser control loaded onto a window form.
I have the folllowing code.
1) DHTML Page
<HTML>
<Title>TestingExternal</Title>
<Head>
<script language="javascript">
var Ext=window.external;
function closewin() {
window.external.close(0);
}
</script>
</Head>
<Body BGCOLOR=TAN>
<input type="button" value="Click" onClick="closewin()"/>
</Body>
<HTML>
I have the c# code below
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
BrowserDemo
{
[System.Runtime.InteropServices.
ComVisibleAttribute(true)]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.ScriptErrorsSuppressed =
false;
webBrowser1.AllowWebBrowserDrop =
false;
webBrowser1.IsWebBrowserContextMenuEnabled =
false;
webBrowser1.WebBrowserShortcutsEnabled =
false;
webBrowser1.ObjectForScripting =
this;
webBrowser1.Navigate(
"F:\\TesttingExternal.htm");
}
public void close(object shutdown)
{
this.Close();
}
public void closeWindow(object shutdown)
{
this.Close();
}
}
}
The avobe code is not working for me .Its giving me Javascript exception while calling the external c# method from javascript.
But if i modify the DHTML page and try to callthe closeWindow(0) then its working fine.
<HTML>
<Title>TestingExternal</Title>
<Head>
<script language="javascript">
var Ext=window.external;
function closewin() {
window.external.closeWindow(0);
}
</script>
</Head>
<Body BGCOLOR=TAN>
<input type="button" value="Click" onClick="closewin()"/>
</Body>
<HTML>
Can anybody tell me what is the problem and how can i run the window.close(0) from the DHTML page.
Waiting for sugesstions.
Thanks
___Das