Advertisement
Guest User

Code-Chrome extension

a guest
Feb 10th, 2012
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //contentscript.js
  2.  
  3. function timedFunction() {
  4. var txt ="shan";
  5. chrome.extension.sendRequest({method:"text",key:txt}, function(response) {
  6.                         d=response.data;
  7.                         alert(d);
  8. });
  9. setTimeout("timedFunction()",2000);
  10. }
  11. timedFunction();
  12.  
  13. //background.html
  14. <!DOCTYPE html>
  15. <html>
  16.   <head>
  17.   </head>
  18.   <body>
  19.     <script type='text/javascript'>
  20. chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
  21.     if (request.method == "text")
  22.     {
  23.       sendResponse({data:request.key});
  24.      }
  25.     else
  26.     {
  27.        
  28.      }    
  29. });
  30.  
  31.   </script>
  32.   </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement