Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to stop the exeution of a javascript function for few seconds

how to stop the exeution of a javascript function for few seconds

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripttutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jagan123
    wrote on last edited by
    #1

    in vb.net we can stop the fuctionality of a code for some time usig threads.in the same way is it possible to stop a javascript fuction for some time

    G 1 Reply Last reply
    0
    • J jagan123

      in vb.net we can stop the fuctionality of a code for some time usig threads.in the same way is it possible to stop a javascript fuction for some time

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Not really. Javascript is strictly single threaded, so if you pause the script for a few seconds, the browser freezes up totally and does nothing until the script continues. If you want the execution of a script to continue after a while, use a timeout to start a function:

      function work() {
      // do something
      window.setTimeout('work2();', 5000); // continue after 5 seconds
      }

      function work2() {
      // continue doing something
      }

      Experience is the sum of all the mistakes you have done.

      J 1 Reply Last reply
      0
      • G Guffa

        Not really. Javascript is strictly single threaded, so if you pause the script for a few seconds, the browser freezes up totally and does nothing until the script continues. If you want the execution of a script to continue after a while, use a timeout to start a function:

        function work() {
        // do something
        window.setTimeout('work2();', 5000); // continue after 5 seconds
        }

        function work2() {
        // continue doing something
        }

        Experience is the sum of all the mistakes you have done.

        J Offline
        J Offline
        jagan123
        wrote on last edited by
        #3

        function work() { // do something window.setTimeout('work2();', 5000); // continue after 5 seconds}function work2() { // continue doing something} sir will u explain once again plz..this example Thanks in advance....

        G 1 Reply Last reply
        0
        • J jagan123

          function work() { // do something window.setTimeout('work2();', 5000); // continue after 5 seconds}function work2() { // continue doing something} sir will u explain once again plz..this example Thanks in advance....

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          The setTimeout method adds a timer in the window object. After the specified time (5000 milliseconds), the code ('work2();') is executed, which will run the work2 function.

          Experience is the sum of all the mistakes you have done.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups