Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome : Event Handler onClick to facebook sharer
    primarykey
    data
    text
    <p>So I'm in alot of trouble now, I have to finish the project in 3 days, and i'm stuck in the links in chrome extension.</p> <p>Project:</p> <p>A google chrome extension that displays all avaible images in the current tab and make the share to several social networks.</p> <p>By now my extension get all images, absolute or dynamic path, from the current tab and display them in the popup.html, and I need to add a image with the facebook logo in the right of the image of the website were it links to sharer.php</p> <p>im using angular.js framwork. My files:</p> <p>Popup.html - this is the div that displays the images.</p> <pre><code> &lt;script src="js/lib/jquery-1.8.2.min.js"&gt;&lt;/script&gt; &lt;script src="js/lib/angular.min.js"&gt;&lt;/script&gt; &lt;script src="js/app/app.js"&gt;&lt;/script&gt; &lt;script src="js/app/popup.js"&gt;&lt;/script&gt; &lt;script src="js/app/bindclick.js"&gt;&lt;/script&gt; &lt;div ng-controller="PageController"&gt; &lt;div&gt;{{message}}&lt;/div&gt; &lt;h2&gt;Page:&lt;/h2&gt; &lt;div&gt;{{title}}&lt;/div&gt; &lt;div id="url"&gt;{{url}}&lt;/div&gt; &lt;h2&gt;Has Links:&lt;/h2&gt; &lt;ul&gt; &lt;li ng-repeat="pageInfo in pageInfos"&gt; &lt;div&gt;&lt;img src={{pageInfo}} class="imagemPopup"/&gt;&lt;img src="http://formaemflor.com.br/loja/skin/frontend/default/perfume/images/facebook_icon.png" class="fblink" style="width: 50px; height: 50px"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>content.js</p> <pre><code>//alert('content script loaded'); chrome.extension.onMessage.addListener( function (request, sender, sendResponse) { if (request.action == 'PageInfo') { var pageInfos = []; $('img').each(function() { pageInfos.push($(this)[0].src); }); sendResponse(pageInfos); } }); </code></pre> <p>popup.js</p> <pre><code>myApp.service('pageInfoService', function() { this.getInfo = function(callback) { var model = {}; chrome.tabs.query({'active': true}, function (tabs) { if (tabs.length &gt; 0) { model.title = tabs[0].title; model.url = tabs[0].url; chrome.tabs.sendMessage(tabs[0].id, { 'action': 'PageInfo' }, function (response) { model.pageInfos = response; callback(model); }); } }); }; }); myApp.controller("PageController", function ($scope, pageInfoService) { pageInfoService.getInfo(function (info) { $scope.title = info.title; $scope.url = info.url; $scope.pageInfos = info.pageInfos; $scope.$apply(); }); }); </code></pre> <p>i want to apply the event handler to the bindclick.js, it should be something like.</p> <pre><code>document.getElementById('.fblink').addEventHandler('click', function(){ var url='http://www.facebook.com/sharer/sharer.php?u='+pageInfo.url; chrome.tabs.create({ url: url }); }); </code></pre> <p>I tryed every thing but I can't make the onclick event to work, can you give me the code? I realy need help of someone who understands chrome extensions, if possible add me skype so I can learn quick beirao94</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload