简体   繁体   English

在新标签页中打开popup.html锚点

[英]Open popup.html anchor in new tab

My problem atm is with manifest v2. 我的问题atm是清单v2。

Since I've been developing this extension I've been facing a lot of problems because the new manifest V2 of google extensions, that removed the capacity of inline javascript in the html files. 自开发此扩展程序以来,我一直面临许多问题,因为google扩展程序的新清单V2删除了html文件中的内联javascript功能。

So can someone tell me how to open a link in a new tab with the new manifest? 有人可以告诉我如何在带有新清单的新标签页中打开链接吗?

My html: 我的html:

<li ng-repeat="pageInfo in pageInfos">
    <img src="{{pageInfo.url}}" class="link"/>
    <img src="http://www.end-timeillusion.com/images/site/sn_icons/facebook.fw.png" class="fbshare"/>
</li>

My external.js - don't work 我的external.js-不起作用

$(document).ready(function(){
    $('.fbshare').click(function(){
        chrome.tabs.create({url: 'http://facebook.com/sharer/sharer.php?u=' + $(.link).attr('src')});
        return false;
    });
});

The problem is this code: 问题是此代码:

$(.link).attr('src')

You need quotation marks around .link, like this: 您需要在.link周围加上引号,如下所示:

$('.link').attr('src')

I tested your code in a test extension and the link opened in a new window, once I added the quotation marks. 添加引号后,我在测试扩展程序中测试了您的代码,并在新窗口中打开了链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM