开发者

JQuery + Dialog Open + Timeout

I have a dialog window in my JSP page and its implemented using jQuery.

If my server is timed-out and I click on a button to open the dialo开发者_JAVA技巧g window, my login-page is shown inside the dialog window.

I want to actually close the dialog window, and redirect to the login page.

How can I achieve this?


Assuming what you are asking is that when you click a link a jquery dialog window opens, or it will redirect you to the login page:

You could have the login link button like so:

 <a href="loginURL">Login</a>

then in the javascript:

  $("a").click(function() {

       if (code to determine if server is not timed-out)
            $("selectorForDialog").dialog({ options });
            return false;
       }
  }

if the server is not timed-out, it will open the dialog, else it will go to the url specified by href in the <a> link

http://jqueryui.com/demos/dialog/


I think what you would need to do in this situation is to create a global function that allows you to "breakout" of the dialog (which I am assuming will use an iframe...). So for instance, in your JSP page, you could create a function such like:

FrameBreakout = function(url) {
  document.location.href = url;
};

And when you render the response for the login page, do something similar to:

if (parent && parent.FrameBreakout)
{
  parent.FrameBreakout("/login.jsp");
}

When that code executes within the iframe (that's why we check for the parent object first) it will cause the outer document to redirect.

That's just a template really, but should lead you in the right direction...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜