cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to close the iView when calling window.close()

Former Member
0 Kudos

Dear All,

I tried to close the iView when user clicks the "exit" button on my WD program.

Below is how I achieve...

1. In your component's interface view, create an exit plug. Name it as - ExitPlug.It's type as "Exit".

2. Create a paramater for this exit plug. Name this parameter "Url". It should be exactly like the same name.

3. In your view add the interface view as a required controller.

4. Create your HTML file. Let's say you call it Static.html.

<html>

<head>

<script langauage="javascript">

function closeWin(){ window.close();

}

</script>\

</head>

<body onUnload="javascript:closeWin()"> </body></html>

5. Save this in the mimes folder for your DC under your package. You do this from the navigator view.

6. in the view with IFrame UI element, wdDoInit(), use WDURLGenerator.getAbsoluteWebResourceURL to get the Static.html

Now,<b> the problem is that the Static.html page is successfully shown when user clicks the "exit" button, but Static.html page stays there without being closed.</b>

What I may do wrongly in my javascript??

I tried couple of combindations, but none of them is working

parent.close()

parent.parent.close()

thanks for any input.

Zita

Accepted Solutions (1)

Accepted Solutions (1)

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Zita,

Try this once in javascript:

var currWindow = window.top;

currWindow.opener = window.top;

currWindow.close();

Regards, Suresh KB

Former Member
0 Kudos

Hi Suresh KB,

Thank you for your solution. I give it a shot but it still does not work though...

I give some alert message in this javascript function and the message is displayed correctly but window still opens.

Zita

Former Member
0 Kudos

By the way, I do not use the Exit plug...because it can not allow me to call an URL in portal....I create a view with IFrame UI element and its source is bound to Static.html page. I use regular outbound plug to call this view.

Answers (2)

Answers (2)

Former Member
0 Kudos

I finally got it to work.

I changed my javascript as follows:

<html>

<head>

<script langauage="javascript">

function closeWindow()

{

var currWindow = window.top;

currWindow.opener = window.top;

currWindow.close();

}

</script>

</head>

<body onload="javascript:closeWindow()">

</body>

</html>

I have no idea why it does work for the first time when I followed Suresh KB's suggestion. Perhaps, the javascript function name is not renamed?? Anyway, I rename the function name and run it again.

And it works now! My window can be closed right after this html page is called.

thanks,

Zita

monalisa_biswal
Contributor
0 Kudos

instead of using "body onUnload" use "body onload"

Former Member
0 Kudos

thank you for your reply, but the result is still the same though.