Can a page be disabled from JavaScript?

Discussion in 'Javascript' started by Tom Szabo, Nov 14, 2004.

  1. Tom Szabo

    Tom Szabo Guest

    Hi All,

    I know that one can disable the page by putting "disabled" into the
    <body....> tag, but can this be done from a java script.


    What I want to achieve is: once the user brings up a "child" window, the
    child disables the parent until the user finished and closes the child, then
    the parent is enabled again...

    TIA,

    Tom
    Tom Szabo, Nov 14, 2004
    #1
    1. Advertising

  2. Tom Szabo

    RobG Guest

    Tom Szabo wrote:
    > Hi All,
    >
    > I know that one can disable the page by putting "disabled" into the
    > <body....> tag, but can this be done from a java script.


    Works for IE, but not for Firefox and I suspect not for any similar
    browser. I didn't test setting it using JavaScript.

    >
    > What I want to achieve is: once the user brings up a "child" window, the
    > child disables the parent until the user finished and closes the child, then
    > the parent is enabled again...


    Effectively you want a modal dialog. You have to be careful with the
    user interface - how will you determine when the user "finishes" with
    the child? What if they just close the child? What if the child is
    closed before it finishes opening, so any onunload you may have to
    re-enable the parent have doesn't get activated? Does the parent stay
    disabled?

    If the parent page really does depend on the outcome of the child page
    then it is likely much better to use traditional navigation.

    Cheers, Rob.
    RobG, Nov 15, 2004
    #2
    1. Advertising

  3. Tom Szabo

    Tom Szabo Guest

    Thanks Rob,

    I understand the implication of this game, but I am implementing a lookup
    form and this is the way it has to work.

    The application mainly for internal use, so I don't really care if not 100%
    compliant

    Thanks,

    Tom



    "RobG" <> wrote in message
    news:GeTld.675$...
    > Tom Szabo wrote:
    > > Hi All,
    > >
    > > I know that one can disable the page by putting "disabled" into the
    > > <body....> tag, but can this be done from a java script.

    >
    > Works for IE, but not for Firefox and I suspect not for any similar
    > browser. I didn't test setting it using JavaScript.
    >
    > >
    > > What I want to achieve is: once the user brings up a "child" window, the
    > > child disables the parent until the user finished and closes the child,

    then
    > > the parent is enabled again...

    >
    > Effectively you want a modal dialog. You have to be careful with the
    > user interface - how will you determine when the user "finishes" with
    > the child? What if they just close the child? What if the child is
    > closed before it finishes opening, so any onunload you may have to
    > re-enable the parent have doesn't get activated? Does the parent stay
    > disabled?
    >
    > If the parent page really does depend on the outcome of the child page
    > then it is likely much better to use traditional navigation.
    >
    > Cheers, Rob.
    Tom Szabo, Nov 15, 2004
    #3
  4. Tom Szabo

    Tom Szabo Guest

    "RobG" <> wrote in message
    news:IXVld.693$...
    > Tom Szabo wrote:
    > > Thanks Rob,
    > >
    > > I understand the implication of this game, but I am implementing a

    lookup
    > > form and this is the way it has to work.
    > >
    > > The application mainly for internal use, so I don't really care if not

    100%
    > > compliant
    > >

    >
    > I had a play with:
    >
    > var b = document.getElementsByTagName('body');
    > b[0].setAttribute('disabled','true');
    >
    > which would seem the correct way to do it according to Microsoft's
    > documentation, however it only partially works - buttons etc. are
    > greyed out and don't work the first time, however clicking them a
    > couple of times brings them back to life. Even using <body disabled>
    > does not fully disable buttons, you can't put content into fields but
    > the buttons still work (scripts still run, submit still submits,
    > reset resets, etc.).
    >
    > Note that none of the above had any effect on non-IE browsers.
    >
    > So I would guess you are out of luck, unless you want to go through all
    > the controls on the page and disable them manually using JavaScript...
    >
    > Cheers, Rob.


    Actually the one-by-one is not a bad suggestion...:)

    I dont mind programming, have been doing it for many years....but I need to
    get this ..

    and thanks for the above,

    Regards,

    Tom
    Tom Szabo, Nov 15, 2004
    #4
  5. Tom Szabo

    RobG Guest

    Tom Szabo wrote:
    > Thanks Rob,
    >
    > I understand the implication of this game, but I am implementing a lookup
    > form and this is the way it has to work.
    >
    > The application mainly for internal use, so I don't really care if not 100%
    > compliant
    >


    I had a play with:

    var b = document.getElementsByTagName('body');
    b[0].setAttribute('disabled','true');

    which would seem the correct way to do it according to Microsoft's
    documentation, however it only partially works - buttons etc. are
    greyed out and don't work the first time, however clicking them a
    couple of times brings them back to life. Even using <body disabled>
    does not fully disable buttons, you can't put content into fields but
    the buttons still work (scripts still run, submit still submits,
    reset resets, etc.).

    Note that none of the above had any effect on non-IE browsers.

    So I would guess you are out of luck, unless you want to go through all
    the controls on the page and disable them manually using JavaScript...

    Cheers, Rob.
    RobG, Nov 15, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c3VuaWwgcGhpbGlw?=

    Check javascript disabled

    =?Utf-8?B?c3VuaWwgcGhpbGlw?=, Mar 14, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    8,619
    balexandre
    Oct 4, 2007
  2. Stu Carter
    Replies:
    6
    Views:
    8,319
    Punisher
    Aug 14, 2003
  3. Simon Brown
    Replies:
    1
    Views:
    4,341
    DWinter
    Aug 8, 2003
  4. David Stahl
    Replies:
    2
    Views:
    451
    David Stahl
    Apr 28, 2004
  5. Replies:
    0
    Views:
    1,309
Loading...

Share This Page