views:

38

answers:

1

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 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?

A: 

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>
Iain Fraser