开发者

How do you detect window.open(...) from within an HTA?

I am developing an HTA that will run as a kiosk in our reception area. This kiosk can display web-pages that launch new windows using the window.open() method.

What I want to do is handle window.open() from within my HTA, so instead of spawning an Internet Explorer window, the new window will appear in a floating iframe inside the HTA.

Any ideas as to how I'd go about doing this?

Here is some pseudocode showing an ideal scenario (although I'm aware the actual solution will probably be more 开发者_Go百科complicated).

function onWindowDotOpen(obj)
{
   spawnNewIframeTab(obj); // Handle the event in the HTA
   return false; // Stop the default behaviour from firing
}

Is there a VBScript solution at all?


I solved my specific problem by overriding the "window.open" of the loaded IFRAME. You can do this in an HTA, but it won't work in a regular browser.

<iframe onload="iframe_onload(this)" src="..."...></iframe>
<script type="text/javascript">
iframe_onload = function(obj)
{
    $(obj).contents().get(0)
    frame.frames.window.open = function(url, name, features, replace)
    {
        ...
    }
}
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜