Results 1 to 2 of 2

Thread: Refreshing a jsp using javascript!!

  1. #1
    Join Date
    Jul 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Refreshing a jsp using javascript!!

    Hi all,
    I wanted to Reload the whole page again after doing a particular action on the page. Is there a refresh or reload functionality using javascript??
    Other than onLoad() in body, but this should be called in a middle of our html code...

    Thanks and Regards,
    Sanjo

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,952
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Usually it is possible and always is better to design your page and plan out whatever it needs to do without having to refresh it after it is loaded. This can have predictably bad consequences for forms and unexpectedly bad consequences in other areas of sever-side code.

    That being said, javascript does provide us with several methods to reload the page. I have put several of them together in one function that tests each before using it against the browser's ability to support it. I've ordered them from the most efficient and modern to the least efficient and archaic:

    Code:
    function doit(){
    if (window.location.reload)
    window.location.reload( true );
    else if (window.location.replace)
    window.location.replace(unescape(location.href));
    else
    window.location.href=unescape(location.href);
    }
    This is by no means meant to be exhaustive but, will probably handle the vast majority of browsers out there without resorting to any sort of browser testing.

    You probably also need a hook to execute the doit() function on but, I'm unclear as to what sort of condition(s) and/or circumstance(s) you would want to trigger this. If things like onresize, onload, etc. won't do (and these type of events have special considerations) then either a poll (last resort) or a hook into an existing bit of code (generally best) would suit. The way a poll works is to periodically test if a certain condition or set of conditions is true and then execute something if they are but, it can take up a lot of resources in many cases.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •