Home > Blockchain >  Transfer content from one tab to another without browser extension possible?
Transfer content from one tab to another without browser extension possible?

Time:01-17

I have a Chrome browser tab with a textarea filled with some ASCII content. I want to open a new tab, load a special URL, where is a HTML document with an empty textarea, and transfer content from the textarea in the first tab to the textarea in the second, newly opened tab.

My question: Is it possible without a browser extension?

Edit: all data are placed in the same domain and server, both are mine, like this:

  • First tab is located under enter image description here

    CodePudding user response:

    So for PHP you both need to make your settings wildcards (or w\e permissions you want) Vs standard init sessions (applies to cookies too) to allow domains to access other subdomains cookies.

    session_set_cookie_params(0, '/', '.domain.com', true);
    session_start();
    

    Also for any JS ajax request you'll need to enable xhr:

                $.ajax({
                    type: method,
                    url:  url,
                    data: request,
                    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                    traditional: true,
                    crossDomain: true,
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function (data) {
                        ...
                    },
                    error: function (xhr, status, thrown) {
                        ...
                    }
                }); |
    

    Neither PHP or JS natively "like" CORS requests these days, even from the same subdomains. They have to be explicitly enabled.

  •  Tags:  
  • Related