更改onBeforeRequest的URL [英] Change URL on onBeforeRequest

查看:301
本文介绍了更改onBeforeRequest的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

  chrome.webRequest.onBeforeRequest.addListener(
function(details){

return {redirectUrl:http://yahoo.com};
},
{
网址:[
'http:// google .com'
],
类型:['main_frame']
},
['blocking']);

这会将google.com重定向到yahoo.com。
我的问题是现在如何在地址栏中保留 google.com ,显示yahoo.com。



我的第一次尝试是使用

chrome.tabs.update(tab.id,{url:details.url}); $ b

但导致网站重新加载。






为什么?



我要求 pdf.js ,因为它讨厌松动PDF URL。 / div>

这是不可能的,你可以通过使用100%x100%的框架来模拟这种效果 - 但仍然,你的问题听起来非常恶意。


I have following code:

chrome.webRequest.onBeforeRequest.addListener(
  function(details) {         

    return { redirectUrl: "http://yahoo.com"};
  },
  {
    urls: [
      'http://google.com'
    ],
    types: ['main_frame']
  },
  ['blocking']);

This is redirecting google.com to yahoo.com. My Question is now howto keep google.com in the addressbar, showing yahoo.com.

My first attempt was to use

chrome.tabs.update(tab.id, {url: details.url});

but that results in an Reloading of the site.


WHY?

I am requesting this for pdf.js, since its anoying to loose the PDF URL.

解决方案

This is not possible, you may simulate this effect by using a 100%x100% frame - but still, your question sounds very malicious.

这篇关于更改onBeforeRequest的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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