How to run function on new tab from main tab? (Google Chrome)

后端 未结 2 1469
时光说笑
时光说笑 2021-01-15 17:54

I need to open console and run one function on new tab, that I opened using javascrip. The opening part is easy, but how to run function on other tab?

2条回答
  •  长情又很酷
    2021-01-15 18:16

    A common solution is using localstorage.

    if (typeof(Storage) !== "undefined") {
      // Code for localStorage/sessionStorage.
      localStorage.setItem("lastname", "Smith");
      var lastname = localStorage.getItem("lastname");
    } else {
        // Sorry! No Web Storage support..
    }
    

提交回复
热议问题