Change URL on onBeforeRequest

旧街凉风 提交于 2019-12-13 04:20:51

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/15359042/change-url-on-onbeforerequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!