Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/common/extensions/docs/content_scripts.html

Issue 412008: Introduce a new 'all_frames' property to content scripts and (Closed)
Patch Set: responses to comments Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/common/extensions/docs/examples/api/messaging/timer/page.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 393
394 <br><br> 394 <br><br>
395 395
396 In the case of <code>"document_idle"</code>, the browser chooses a time to i nject scripts between <code>"document_end"</code> and immediately after the <cod e><a href="http://www.whatwg.org/specs/web-apps/current-work/#handler-onload">wi ndow.onload</a></code> event fires. The exact moment of injection depends on how complex the document is and how long it is taking to load, and is optimized for page load speed. 396 In the case of <code>"document_idle"</code>, the browser chooses a time to i nject scripts between <code>"document_end"</code> and immediately after the <cod e><a href="http://www.whatwg.org/specs/web-apps/current-work/#handler-onload">wi ndow.onload</a></code> event fires. The exact moment of injection depends on how complex the document is and how long it is taking to load, and is optimized for page load speed.
397 397
398 <br><br> 398 <br><br>
399 399
400 <b>NOTE:</b> In <code>document_idle</code>, content scripts may not necessar ily receive the window.onload event, because they may run after it has 400 <b>NOTE:</b> In <code>document_idle</code>, content scripts may not necessar ily receive the window.onload event, because they may run after it has
401 already fired. In most cases, listening for the onload event is unnecessary for content scripts running at <code>document_idle</code> because they are guara nteed to run after the DOM is complete. If your script definitely needs to run a fter <code>window.onload</code> you can check if it has already fired by using t he <code><a href="http://www.whatwg.org/specs/web-apps/current-work/#dom-documen t-readystate">document.readyState</a></code> property.</td> 401 already fired. In most cases, listening for the onload event is unnecessary for content scripts running at <code>document_idle</code> because they are guara nteed to run after the DOM is complete. If your script definitely needs to run a fter <code>window.onload</code> you can check if it has already fired by using t he <code><a href="http://www.whatwg.org/specs/web-apps/current-work/#dom-documen t-readystate">document.readyState</a></code> property.</td>
402 </tr> 402 </tr>
403 <tr>
404 <td>all_frames</td>
405 <td>boolean</td>
406 <td><em>Optional.</em>
407 Controls whether the content script runs in all frames of the matching page, or only the top frame.
408 <br><br>
409 Defaults to <code>false</code>, meaning that only the top frame is matched.< /td>
410 </tr>
403 </tbody></table> 411 </tbody></table>
404 412
405 413
406 <h2 id="execution-environment">Execution environment</h2> 414 <h2 id="execution-environment">Execution environment</h2>
407 415
408 <p>Content scripts execute in a special environment called an <em>isolated world </em>. They have access to the DOM of the page they are injected into, but not t o any JavaScript variables or functions created by the page. It looks to each co ntent script as if there is no other JavaScript executing on the page it is runn ing on. The same is true in reverse: JavaScript running on the page cannot call any functions or access any variables defined by content scripts. 416 <p>Content scripts execute in a special environment called an <em>isolated world </em>. They have access to the DOM of the page they are injected into, but not t o any JavaScript variables or functions created by the page. It looks to each co ntent script as if there is no other JavaScript executing on the page it is runn ing on. The same is true in reverse: JavaScript running on the page cannot call any functions or access any variables defined by content scripts.
409 417
410 </p><p>For example, consider this simple page: 418 </p><p>For example, consider this simple page:
411 419
412 </p><pre>hello.html 420 </p><pre>hello.html
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 urchinTracker(); 669 urchinTracker();
662 } 670 }
663 catch(e) {/* urchinTracker not available. */} 671 catch(e) {/* urchinTracker not available. */}
664 </script> 672 </script>
665 <!-- end analytics --> 673 <!-- end analytics -->
666 </div> 674 </div>
667 </div> <!-- /gc-footer --> 675 </div> <!-- /gc-footer -->
668 </div> <!-- /gc-container --> 676 </div> <!-- /gc-container -->
669 </body></html> 677 </body></html>
670 678
OLDNEW
« no previous file with comments | « chrome/chrome.gyp ('k') | chrome/common/extensions/docs/examples/api/messaging/timer/page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698