tags:

views:

53

answers:

1

Let's assume a simple application, which has at the top the following navigation (pseudo code):

<a href="?action=new">New</a>
<a href="?action=search">Search</a>

Below, there are different sections, i.e. for the "New" mask:

<div id="condition">
    <form>
        <input type="text" name="Login" />
        <input type="text" name="First" />
        <a href="javascript:performSearch()">Perform search</a>
    </form>
</div>
<div id="results"
    <table>
    ..
    </table
</div>

Let's assume that the session times out and the user clicks on ...

  • New: the content returned from the server will be loaded "full screen" and has to include header/footer/etc
  • Perform search: the content will be displayed within the results DIV: should be only a short error message

Question:

  • is there a way to identify via JavaScript (in the "error.html") if the current content is loaded into a DIV or "fullscreen"?
  • should I always return an element which spans the whole browser window?
  • or is there a different way to handle this situation?

Any suggestions or ideas are appreciated.

A: 

is there a way to identify via JavaScript (in the "error.html") if the current content is loaded into a DIV or "fullscreen"? Or is there a different way to handle this situation?

I don't think it really matters!

Not 100% sure this answers your question, but here's what I'd do:

Have an invisible error div in every page.

<div id="errordiv" style="display: none">Error!</div>

Make it span the whole browser window.

div#errordiv
 {
    position: fixed; // Works everywhere except IE 6
    left: 0px; top: 0px; right: 0px; bottom: 0px;
    background-color: white; // or whatever

  }

if an error occurs when you run your JavaScript (regardless in what context!), make the error div visible:

document.getElementById("errordiv").style.display = "block";

add the error message

document.getElementById("errordiv").style.innerHTML= 
                     "<h1>Error</h1>An error has occurred.....";

(of course, you'd wrap all this into one central showError() function)

if an error occurs during server-side handling, make it visible from the start (how to do that, differs from language to language).

Pekka