Chrome扩展程序弹出页面链接不起作用 [英] Chrome extension popup page link doesn't work

查看:62
本文介绍了Chrome扩展程序弹出页面链接不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Chrome扩展程序来娱乐,但弹出页面出现问题.我使用jQuery load()函数加载了一部分现有页面,例如: http://aaa.com :

I was creating a Chrome extension for fun, but i got a problem with my popup page. I used jQuery load() function to load a part of existed page, let's say: http://aaa.com:

<div id="aaa-news">
$(document).ready(function(){
     $("#ox-news").load("http://aaa/News/ .news_list");
});
</div>

自从我试图加载到popup.html的页面部分以来,其中包含一些链接,但是这些链接的href属性似乎在Chrome每次加载到popup.html时都被Chrome修改了.即使我使用了chrome.tabs,也是如此.create.* API打开一个新标签,它总是向我显示

Since the part of page i tried to load into popup.html contains some links, but seems href attributes of these links have been modified by Chrome whenever they are loaded in popup.html.So even if i used chrome.tabs.create.* API to open a new tab, it always showed me

找不到该网址的网页: Chrome浏览器扩展程序://phigdpgmolbpdcihdohfpbafibncbkhl/新闻/1 错误6(net :: ERR_FILE_NOT_FOUND):找不到文件或目录.

No webpage was found for the web address: Chrome extension://phigdpgmolbpdcihdohfpbafibncbkhl/News/1 Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.

有人知道吗?感谢您的帮助!

Anyone has idea? Appreciated for your help!

推荐答案

要修复相对链接,可以使用< base> 标记.通过设置 target ="_ blank" (否则链接将变得不可单击),使弹出窗口中的所有链接在选项卡中打开也很有用:

To fix relative links you can use <base> tag. It is also useful to make all links inside popup to open in a tab by setting target="_blank" (otherwise links become non-clickable):

<base href="http://aaa/" />
<base target="_blank" />

这篇关于Chrome扩展程序弹出页面链接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆