Files
webextensions-examples/content-script-page-script-messaging.html
T
2017-01-20 17:47:50 -08:00

17 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="page-styles/styles.css" type="text/css"/>
</head>
<body>
<p>This page demonstrates messaging between page scripts and content scripts.</p>
<p>To try it out, first install the WebExtension from <a href="https://github.com/mdn/webextensions-examples/tree/master/page-to-extension-messaging">https://github.com/mdn/webextensions-examples/tree/master/page-to-extension-messaging</a>, then reload this page.</p>
<p>Clicking one button sends a message from the page script to the content script: the content script just displays an alert when it receives the message. Clicking the other button sends a message the other way.</p>
<input id="from-page-script" type="button" value="Send a message from the page script"></input>
<input id="from-content-script" type="button" value="Send a message from the content script"></input>
<script src="page-scripts/page-script-to-content-script-messaging.js"></script>
</body>
</html>