HTML 5 webworkers with multiple arguments

前端 未结 1 1993
轻奢々
轻奢々 2021-01-18 02:53

I just got into HTML5 webworkers and now I want to pass multiple arguments to my worker.

I have this in my page:

var username = document.getElemen         


        
相关标签:
1条回答
  • 2021-01-18 03:38

    Post like this:

    w.postMessage({ 
        user: username, 
        url: server_url 
    })
    

    on message event do:

    onmessage = function (e) {
        username = e.data.user;
        server_url = e.data.url;
    }
    
    0 讨论(0)
提交回复
热议问题