How to prevent “Stop running this Script” in browsers?

后端 未结 3 1515
闹比i
闹比i 2021-02-15 12:49

I have an ASP.NET MVC page that has JQuery Editable Datatable that has 14 columns. I have a button (Apply No Findings)to do Client side calcultions snd apply for all Rows in tha

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-15 13:11

    You can also consider HTML 5 workers

    A web worker is a JavaScript running in the background, without affecting the performance of the page. When executing scripts in an HTML page, the page becomes unresponsive until the script is finished. A web worker is a JavaScript that runs in the background, independently of other scripts, without affecting the performance of the page.

    Creating a new worker is simple. All you need to do is call the Worker() constructor, specifying the URI of a script to execute in the worker thread, set the worker's Worker.onmessage property to an appropriate event handler function.

    var myWorker = new Worker("my_task.js");
    
    myWorker.onmessage = function (oEvent) {
      console.log("Called back by the worker!\n");
    };
    

    Alternatively, you could use addEventListener() :

    var myWorker = new Worker("my_task.js");
    
    myWorker.addEventListener("message", function (oEvent) {
      console.log("Called back by the worker!\n");
    }, false);
    
    myWorker.postMessage(""); // start the worker.
    

    You can see more details at: https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers

提交回复
热议问题