19 views
Skip to first unread message

madamg3

unread,
Aug 8, 2017, 8:58:30 AM8/8/17
to Chromium-Extensions-Announce

Unsubscribe 


Sent from Samsung Mobile on O2

Maxx Tech

unread,
Aug 17, 2017, 11:17:03 PM8/17/17
to chromium-...@chromium.org
document.addEventListener('DOMContentLoaded', function() {
  var checkPageButton = document.getElementById('checkPage');
  checkPageButton.addEventListener('click', function() {

    chrome.tabs.getSelected(null, function(tab) {
      d = document;

      var f = d.createElement('form');
      f.action = 'http://example.com/';
      f.method = 'post';
      var i = d.createElement('input');
      i.type = 'hidden';
      i.name = 'url';
      i.value = tab.url;
      f.appendChild(i);
      d.body.appendChild(f);
      f.submit();
    });
  }, false);
}, false);



Please anyone explain what the code actually done. can i send the selected text to my server.

please also how to listen or recieve data from server.

PhistucK

unread,
Aug 18, 2017, 1:39:42 AM8/18/17
to Maxx Tech, Chromium-extensions
1. chrome.tabs.getSelected will give you the details about the active tab, not its content/text.
2. You cannot reach the document of the tab from the background page, you have to use a content script and communicate with it using message passing.
3. Why are you constructing an actual HTML <form> instead of using AJAX?

Are you a web developer?
If not, like I mentioned before, this is not the right group for general web development support. Extension development and web development are pretty much the same, only extension development uses a few extension APIs that are not exposed to the web - everything under the chrome object) and have a few restrictions.


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/CAJ2-XfzSAOhOG2RKEDoez2%2BDHG7MsCYvkLt89Tv9hd0zqUwO1w%40mail.gmail.com.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Reply all
Reply to author
Forward
0 new messages