You are viewing limited content. For full access, please sign in.

Question

Question

Web access custom tools - Close window

asked on February 17, 2017 Show version history

I've added a custom button to Web access by modiying customactions.xml. Issue is no matter what javascript code I use, I can not get to close the tool window. We need for the window to close on close button or when the user is done selecting information needed. I've tried -

ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true);

Also tried client side script on aspx page, and adding client side html button with onclick command and all different methods. Thanks.

0 0

Replies

replied on February 17, 2017

"window.close()" should be able to close the tab, see this demo.  Adding a button to the html/aspx is probably the simplest approach.  There are restrictions on which windows you are allowed to close via javascript, so you might need to change how you are opening the window in the first place.

0 0
replied on February 17, 2017 Show version history

Thanks. All these scripts are already tried since this is usual method of closing window. But adding button and opening window is controlled by code provided by Laserfiche. So we can not change that. We can only modify custonactions.xml. That's why checking if there is any code to close window also.

0 0
replied on February 22, 2017

Oh, I missed that this isn't really a new window but just a Web Access dialog.  Since those dialogs are loaded into an iframe, window.close() isn't going to work.  What you need to do is to call .Close() on the dialog object.  The name of the dialog object should be passed to your aspx page in the "dialog" query string parameter, and this will represent a Javascript object that lives in Web Access.

So, you would run something like:

window.parent.waWindow.<%= Request.QueryString["dialog"] %>.Close();

0 0
replied on February 22, 2017

I had a feeling that I'll need to use the same object. I had tried following code. Let me look into implementing your solution.

 DialogPage dp = new DialogPage();

            dp.ValueToSet = "";

            dp.Closed = true;
            dp.UpdateInitializeScript();

0 0
replied on February 22, 2017

If you want to use DialogPage for this, you should be subclassing it in your page.  If you just instantiate it, it will be disconnected from the current HttpRequest and won't write anything to the browser.

0 0
replied on February 23, 2017 Show version history

I tried window.parent.waWindow.myDialog.Close();

myDialog is the querystring value. Added that in onlick on html button. That didn't close the dialog.

<input id="Button1" type="button" value="Close" onclick="window.parent.waWindow.myDialog.Close();" />

This is what I am using to open the window -

<ActionDefinition ID="LFRouterMD">
        <Title>MD-Router</Title>
        <Action>
            <![CDATA[
            var selectObj =         context.getSelectedItems("ENTRIES");
            var selectedEntries = selectObj.items;
            var entry = selectedEntries[0];
        
            var dobj = waWindow.getAvailableDlg(); 
            dobj.OpenDialog("Router.aspx?docID=" +         entry.id, 600, 700, true);
            dobj.onclose = function() {
                metadataControl.refresh();
            }
            ]]>
        </Action>
        <Enabled>
            <![CDATA[
            return true;
            ]]> 
        </Enabled>
        <IconClass>LFRouterIcon</IconClass>
        <Toolbars>3</Toolbars>
</ActionDefinition >

 

0 0
replied on February 23, 2017

Was there an error in the console?  What do you see if you step through the code with a debugger?

0 0
replied on February 23, 2017 Show version history

There is no error. It is html button with onlick in client side.  That is the only change made. it is not server side code.

<input id="Button1" type="button" value="Close" onclick="window.parent.waWindow.myDialog.Close();" />

0 0
replied on February 23, 2017

Yes, I mean the browser console and debugging in the browser.  Is it not finding the myDialog object?  Does it not have a Close() function?  Is it calling into it successfully but still not having the desired effect?

0 0
replied on March 1, 2017 Show version history

It finds mydialog and it has close function but no reaction to button click. Is there any way to have remote session? I can post solution here once it's resolved.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.