can not get alert to call from setTimeout

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lkrubner@geocities.com

    can not get alert to call from setTimeout

    Is there any reason why this code wouldn't prompt someone to save their
    work every 5 minutes? It doesn't seem to be working. This code shows up
    in the HEAD of an HTML document.



    function saveYourWorkRem inder() {
    alert("It's been 5 minutes. Please save your work. Web browsers are
    buggy and crash often. Protect yourself!");
    }

    setTimeout("sav eYourWorkRemind er", 300000);

  • McKirahan

    #2
    Re: can not get alert to call from setTimeout

    <lkrubner@geoci ties.com> wrote in message
    news:1102520247 .074595.149020@ f14g2000cwb.goo glegroups.com.. .[color=blue]
    > Is there any reason why this code wouldn't prompt someone to save their
    > work every 5 minutes? It doesn't seem to be working. This code shows up
    > in the HEAD of an HTML document.
    >
    >
    >
    > function saveYourWorkRem inder() {
    > alert("It's been 5 minutes. Please save your work. Web browsers are
    > buggy and crash often. Protect yourself!");
    > }
    >
    > setTimeout("sav eYourWorkRemind er", 300000);
    >[/color]

    Perhaps missing parentheses?

    setTimeout("sav eYourWorkRemind er()", 300000);


    BTW, what does your inteneded audience do with a Web browser that require
    them to save their work? What would they save and how would they retrieve
    it later?


    Comment

    • Rob B

      #3
      Re: can not get alert to call from setTimeout

      McKirahan wrote:
      [color=blue]
      > <lkrubner@geoci ties.com> wrote in message
      > news:1102520247 .074595.149020@ f14g2000cwb.goo glegroups.com.. .[color=green]
      > > Is there any reason why this code wouldn't prompt someone to save[/color][/color]
      their[color=blue][color=green]
      > > work every 5 minutes? It doesn't seem to be working. This code shows[/color][/color]
      up[color=blue][color=green]
      > > in the HEAD of an HTML document.
      > >
      > >
      > >
      > > function saveYourWorkRem inder() {
      > > alert("It's been 5 minutes. Please save your work. Web browsers are
      > > buggy and crash often. Protect yourself!");
      > > }
      > >
      > > setTimeout("sav eYourWorkRemind er", 300000);
      > >[/color][/color]
      [color=blue]
      >Perhaps missing parentheses?[/color]
      [color=blue]
      >setTimeout("sa veYourWorkRemin der()", 300000);[/color]

      (snip)

      You can use a function pointer (function name without parentheses), but
      it's a variable name and so takes no quotes:

      setTimeout(save YourWorkReminde r, 300000);

      The alert string needs to be on one line (probably is where you are).

      Why not pop up a link to a decent web browser? :o

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • lkrubner@geocities.com

        #4
        Re: can not get alert to call from setTimeout

        Thank you. I'll write it like this:

        setTimeout("sav eYourWorkRemind er()", 300000);

        When you say "decent web browser" are you speaking of one that allows
        you to save the stuff you are writing in a textarea? I was in a big
        online discussion about this problem perhaps 11 months ago and at that
        time it seemed that there were no browsers that did a reasonable job as
        word processors. Have things changed? What are you referring to?

        Comment

        • lkrubner@geocities.com

          #5
          Re: can not get alert to call from setTimeout

          Personally, I'm tired of losing my work because some web browser has
          crashed. I do a lot of my best writing in the textarea box of some
          form. I hate losing work and yet it happens often. Some of the best
          weblog posts I've ever written ceased to exist because the web browser
          I was using crashed. Some of the best love letters I've ever written
          never reached their audience because of the damned browser. For a lot
          of people, web browsers have replaced word processors as the place
          where they do most of their writing. Yet you can not save your work
          when you are in a web browser. It is painful to spend an hour on a
          letter and then the browser crashes and you lose all your work.

          But the browsers are not the only source of trouble when it comes to
          writing online. Most email companies will end your session without
          warning and without saving your work. If you spend an hour writing a
          love letter in Hotmail and then hit "Send", Hotmail will wipe out your
          work and take you back to the login screen.

          Me and some friends have been working on a content management system,
          and we hope to mitigate these problems. Ultimately, it is a problem
          that the browser vendors need to solve, but till that day we are using
          common sense and javascript to offer what minor protections we can.
          With our software, when your session ends you get taken back to the
          login screen, just like in Hotmail, but everything you just posted is
          shown on the screen, so you can copy it, log back in, and paste it into
          a form. That's a minor protection we offer that I wish Hotmail and
          Yahoo and Earthlink offered. Also, we have a "Save" button sitting
          above our textarea boxes. The save button doesn't do anything more than
          grab the text in the textarea and send it to a new window, but at least
          you can then save that new window to your harddrive and get some of the
          protection you might expect to get by saving often in a word processor.

          Comment

          • Dr John Stockton

            #6
            Re: can not get alert to call from setTimeout

            JRS: In article <ktFtd.628430$m D.506587@attbi_ s02>, dated Wed, 8 Dec
            2004 15:54:56, seen in news:comp.lang. javascript, McKirahan
            <News@McKirahan .com> posted :[color=blue]
            >
            >BTW, what does your inteneded audience do with a Web browser that require
            >them to save their work? What would they save and how would they retrieve
            >it later?[/color]

            When filling in a large text-area, perhaps composing a news article, one
            can in Windows copy'n'paste the lot to Notepad and save on disc.

            If the server collaborated, one could send it a part-text to be kept and
            returned on request, with a different button to send completed work.

            Etc.

            --
            © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
            <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
            <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
            <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

            Comment

            • McKirahan

              #7
              Re: can not get alert to call from setTimeout

              <lkrubner@geoci ties.com> wrote in message
              news:1102550379 .364907.9340@c1 3g2000cwb.googl egroups.com...[color=blue]
              > Personally, I'm tired of losing my work because some web browser has
              > crashed. I do a lot of my best writing in the textarea box of some
              > form. I hate losing work and yet it happens often. Some of the best
              > weblog posts I've ever written ceased to exist because the web browser
              > I was using crashed. Some of the best love letters I've ever written
              > never reached their audience because of the damned browser. For a lot
              > of people, web browsers have replaced word processors as the place
              > where they do most of their writing. Yet you can not save your work
              > when you are in a web browser. It is painful to spend an hour on a
              > letter and then the browser crashes and you lose all your work.
              >
              > But the browsers are not the only source of trouble when it comes to
              > writing online. Most email companies will end your session without
              > warning and without saving your work. If you spend an hour writing a
              > love letter in Hotmail and then hit "Send", Hotmail will wipe out your
              > work and take you back to the login screen.
              >
              > Me and some friends have been working on a content management system,
              > and we hope to mitigate these problems. Ultimately, it is a problem
              > that the browser vendors need to solve, but till that day we are using
              > common sense and javascript to offer what minor protections we can.
              > With our software, when your session ends you get taken back to the
              > login screen, just like in Hotmail, but everything you just posted is
              > shown on the screen, so you can copy it, log back in, and paste it into
              > a form. That's a minor protection we offer that I wish Hotmail and
              > Yahoo and Earthlink offered. Also, we have a "Save" button sitting
              > above our textarea boxes. The save button doesn't do anything more than
              > grab the text in the textarea and send it to a new window, but at least
              > you can then save that new window to your harddrive and get some of the
              > protection you might expect to get by saving often in a word processor.
              >[/color]

              If its such a problem then how about periodically (every minute or so)
              having your script highlight the textarea and copy it to the clipboard (and
              save it via FSO to a file if you want)?


              Comment

              • McKirahan

                #8
                Re: can not get alert to call from setTimeout

                "McKirahan" <News@McKirahan .com> wrote in message
                news:vANtd.1629 77$5K2.51522@at tbi_s03...

                [snip]
                [color=blue]
                > If its such a problem then how about periodically (every minute or so)
                > having your script highlight the textarea and copy it to the clipboard[/color]
                (and[color=blue]
                > save it via FSO to a file if you want)?[/color]

                Or just manually highlight the text periodically (via Ctrl+A) and save it to
                the clipboard (via Ctrl+C or Ctrl+Insert). Then, if your browser crashes,
                just open up Notepad and press Ctrl+V (or Shift+Insert) to paste what you
                last "saved".

                I also look into why your browser crashes so frequently; it's not something
                that happens to most of us.


                Comment

                • RobB

                  #9
                  Re: can not get alert to call from setTimeout

                  McKirahan wrote:

                  (snip)
                  [color=blue]
                  > I also look into why your browser crashes so frequently; it's not[/color]
                  something[color=blue]
                  > that happens to most of us.[/color]

                  My point as well. Although Internet Explorer dies on occasion - with
                  the familiar '...sorry for the inconvenience' lament - I can't recall
                  the last time a Mozilla/Gecko UA, Opera, Safari did. When it did, I
                  suspect it had something to do with Flash, or convoluted scripting, or
                  plugins.

                  Presumably your users don't expect any persistence when moving back &
                  forth between pages, so this 'crashing' occurs within your own page(s).
                  Why might that be?

                  Comment

                  • lkrubner@geocities.com

                    #10
                    Re: can not get alert to call from setTimeout

                    Browser's crash often no matter the operating system or computer or
                    browser. Safari on OS X crashes and Netscape 7.1 on Linux crashes and
                    IE on Windows 95 or XP crashes. There is no escaping browser crashes.
                    For that matter, there is no escaping crashes in, say, Microsoft Word,
                    but with Word it is easier to save every few minutes.

                    [color=blue][color=green][color=darkred]
                    >>>>>>>>>>>>>>> .[/color][/color][/color]
                    Or just manually highlight the text periodically (via Ctrl+A) and save
                    it to
                    the clipboard (via Ctrl+C or Ctrl+Insert). Then, if your browser
                    crashes,
                    just open up Notepad and press Ctrl+V (or Shift+Insert) to paste what
                    you
                    last "saved".[color=blue][color=green][color=darkred]
                    >>>>>>>>>>>>> >>[/color][/color][/color]

                    No good - often when a browser crashes it crashes the whole computer.
                    I've lost tons of work this way and so has every single person that I
                    know. Talk to any college kid, you'll find they are resigned to it -
                    that most software is bad and crashes often and data is lost is assumed
                    to be a fact of life.

                    Comment

                    • lkrubner@geocities.com

                      #11
                      Re: can not get alert to call from setTimeout

                      >>>>>>>>>>>>
                      When it did, I
                      suspect it had something to do with Flash, or convoluted scripting, or
                      plugins.[color=blue][color=green][color=darkred]
                      >>>>>>>>>>>>[/color][/color][/color]

                      Um, your point? As far as I know, the web will always have Flash,
                      convoluted scripting, bad plugins, badly done Java, non-valid HTML,
                      server timeouts and lost internet connections. Writing code as if
                      someday all these problems will go away strikes me as unrealistic.

                      Flash, in particular, seems to crash certain browsers. I can't tell you
                      how many times I've been writing something, then decided I needed to
                      look up a fact, so I open a new browser window and go to Google to
                      research the fact, then click through to one of the sites that Google
                      brings up, only to have that new site crash the whole browser, because
                      of some damn stupid advertisement.

                      [color=blue][color=green][color=darkred]
                      >>>>>>>>>>>>> >[/color][/color][/color]
                      Presumably your users don't expect any persistence when moving back &
                      forth between pages, so this 'crashing' occurs within your own page(s).
                      Why might that be?[color=blue][color=green][color=darkred]
                      >>>>>>>>>>>>> >[/color][/color][/color]

                      I can try to keep my own pages free of Flash, convoluted scripting, and
                      plug-ins, but I doubt that my users will only be using my site when
                      they are working. I don't know many people who do much serious work on
                      the web while keeping just one window open.

                      Comment

                      • lkrubner@geocities.com

                        #12
                        Re: can not get alert to call from setTimeout

                        >>>>>>>>>>
                        When filling in a large text-area, perhaps composing a news article,
                        one
                        can in Windows copy'n'paste the lot to Notepad and save on disc.

                        If the server collaborated, one could send it a part-text to be kept
                        and
                        returned on request, with a different button to send completed work.[color=blue][color=green][color=darkred]
                        >>>>>>>>>>[/color][/color][/color]

                        That's what I do personally but what I need to do now is automate
                        something like that for my end users. What you describe is too complex
                        so I'm looking for ways to simplify.

                        Comment

                        • lkrubner@geocities.com

                          #13
                          Re: can not get alert to call from setTimeout

                          Isn't FSO limited to the Microsoft world? It's an ActiveX object, isn't
                          it? All our code is open-sourse PHP and Javascript, so ActiveX isn't an
                          option for us. Even if it was, I'd hate myself if I started telling
                          users "Just use IE for everything."

                          Comment

                          Working...