sounds odd, why do you ever need to call javascript code? consider to expose some event, and have the javascript provide the event handler, seehttp://weblogs.asp.net/stevencohn/archive/2004/05/24/140201.aspx
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=ap3drj%243mb%2407%241%40news.t-online.com

解决方案 »

  1.   

    比如我要在用户控件中关闭IE窗口,使用FindForm()方法时,如果宿主是IE,则会返回NULL,如果宿主是WINFORM,则可以。而如果强制关闭线程的话,则会将打开的所有IE都关掉了。所以想让它执行页面的JS来进行关闭窗口。
      

  2.   

    你可以把窗口的标题传给控件的一个属性,然后由控件去寻找IE的窗口,寻找窗口有两种方式,第一种是用Windows API,第二种是用Shell,利用Shell提供的接口访问Windows文件夹窗口和IE窗口,在Delphi的《未经验证的葵花宝典》中有这样的文章。
    我自己做过隐藏所有IE窗口的例子,都找到了啊,只是没有实现关闭的消息而已,你再试试吧。用第二种也肯定可以取到,我只是做过试验而已。
      

  3.   

    按照“http://weblogs.asp.net/stevencohn/archive/2004/05/24/140201.aspx”的方法,实现不了,不明白需要调用的JS函数应写在哪里?
      

  4.   

    something like
    <OBJECT id="Button2"
    classid="http://localhost/MyDir/MyButtonControl.dll#MyButtonControl.MyButton
    " VIEWASTEXT>
       </OBJECT>
       <script language="javascript" for="Button2" event="MyButtonClicked()">
       <!--
        // after catching the user event do some stuff...
       window.location.href = "SomeUrl.aspx";
       //-->
       </script>