OLD | NEW |
1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: | 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: |
2 1) The <head> information in this page is significant, should be uniform | 2 1) The <head> information in this page is significant, should be uniform |
3 across api docs and should be edited only with knowledge of the | 3 across api docs and should be edited only with knowledge of the |
4 templating mechanism. | 4 templating mechanism. |
5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a | 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a |
6 browser, it will be re-generated from the template, json schema and | 6 browser, it will be re-generated from the template, json schema and |
7 authored overview content. | 7 authored overview content. |
8 4) The <body>.innerHTML is also generated by an offline step so that this | 8 4) The <body>.innerHTML is also generated by an offline step so that this |
9 page may easily be indexed by search engines. | 9 page may easily be indexed by search engines. |
10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> | 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 Here is how you open a channel from a content script, and send and listen for | 453 Here is how you open a channel from a content script, and send and listen for |
454 messages: | 454 messages: |
455 </p><pre>contentscript.js | 455 </p><pre>contentscript.js |
456 ================ | 456 ================ |
457 var port = chrome.extension.connect({name: "knockknock"}); | 457 var port = chrome.extension.connect({name: "knockknock"}); |
458 port.postMessage({joke: "Knock knock"}); | 458 port.postMessage({joke: "Knock knock"}); |
459 port.onMessage.addListener(function(msg) { | 459 port.onMessage.addListener(function(msg) { |
460 if (msg.question == "Who's there?") | 460 if (msg.question == "Who's there?") |
461 port.postMessage({answer: "Madame"}); | 461 port.postMessage({answer: "Madame"}); |
462 else if (msg.question == "Madame who?") | 462 else if (msg.question == "Madame who?") |
463 port.postMessage({answer: "Madame... Bovary"); | 463 port.postMessage({answer: "Madame... Bovary"}); |
464 }); | 464 }); |
465 </pre> | 465 </pre> |
466 | 466 |
467 <p> | 467 <p> |
468 Sending a request from the extension to a content script looks very similar, | 468 Sending a request from the extension to a content script looks very similar, |
469 except that you need to specify which tab to connect to. Simply replace the | 469 except that you need to specify which tab to connect to. Simply replace the |
470 call to connect in the above example with | 470 call to connect in the above example with |
471 <a href="tabs.html#method-connect">chrome.tabs.connect(tabId, {name: | 471 <a href="tabs.html#method-connect">chrome.tabs.connect(tabId, {name: |
472 "knockknock"})</a>. | 472 "knockknock"})</a>. |
473 | 473 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 _uff=0; | 799 _uff=0; |
800 urchinTracker(); | 800 urchinTracker(); |
801 } | 801 } |
802 catch(e) {/* urchinTracker not available. */} | 802 catch(e) {/* urchinTracker not available. */} |
803 </script> | 803 </script> |
804 <!-- end analytics --> | 804 <!-- end analytics --> |
805 </div> | 805 </div> |
806 </div> <!-- /gc-footer --> | 806 </div> <!-- /gc-footer --> |
807 </div> <!-- /gc-container --> | 807 </div> <!-- /gc-container --> |
808 </body></html> | 808 </body></html> |
OLD | NEW |