使Chrome扩展程序弹出窗口透明

编程入门 行业动态 更新时间:2024-10-28 12:17:26
本文介绍了使Chrome扩展程序弹出窗口透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在写一个chrome扩展程序.我想知道是否有一种方法可以使弹出窗口透明,也就是说,即使弹出窗口覆盖了它,用户也可以看到当前页面的内容.谢谢!

I am writing a chrome extension. I am wondering if there is a way to make the popup window transparent, that is the user can see the content of the current page even the popup window covers it. Thank you!

推荐答案

昨天我想到一个有趣的主意,尽管您不能删除白色背景,但仍然可以模仿透明背景

An interesting idea came to me mind yesterday, though you can't remove the white background, you can still mimic a transparent background.

这可以通过在打开弹出窗口之前拍摄页面的屏幕截图并将其作为弹出窗口的背景图像来完成. 我不确定背景图像的位置计算将如何进行,即使可能,也可以尝试一下.

This will be done by taking a screenshot of the page right before opening the popup and place it as a background image of the popup. I'm not sure how the background-image position calculations will go and if even possible but go give it a try.

当然,您仍然会看到弹出窗口的白色边框和阴影框,但是它看起来仍然应该不错.

Of course you will still have the popup's white border and box-shadow, but it should still look quite good.

请注意,如果弹出窗口后面有任何移动,此技巧可能无法奏效,例如:

Notice that this trick may not work good if there is any movement behind the popup as:

  • 视频/音频播放器
  • 图像滑块
  • 广告横幅
  • 自动更新新闻提要(社交媒体)
  • CSS动画
  • 等等...

使用背景脚本中的captureVisibleTab进行屏幕截图: developer.chrome/extensions/tabs#method-captureVisibleTab

Taking a screenshot is done using captureVisibleTab from a background-script: developer.chrome/extensions/tabs#method-captureVisibleTab

您将使用消息或存储将屏幕截图图像数据发送到弹出窗口.

You will use messages or storage to send the screenshot image data to the popup.

更多推荐

使Chrome扩展程序弹出窗口透明

本文发布于:2023-08-06 05:18:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1310292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹出窗口   透明   程序   Chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!