小书签可以用来覆盖网页上的图像吗?不是作为弹出窗口,而是作为由 CSS 定位并具有高 z-index 以显示在其他元素之上的图像。并且没有 mask ,即 Shadowbox 或类似的 jQuery 效果。只是来自 URL 的图像,位于浏览器窗口的左下角。
这是我目前的情况,但可能是错误的方向:
javascript:(function(){document.write("<style type='text/css'>body {background-image:url(http://example.com/image.png); position: absolute; left:50px; top:300px; z-index:9999;}</style>");})()
我有一个 JS 函数可以用作书签来更改页面上文本的大小写,现在我希望能够在使用书签时显示图像。
最佳答案
如果您希望图像覆盖 页面,则为正文设置背景 图像将无济于事。此外,document.write
不能直接用于添加 CSS 样式。
您可能想要做的是向页面添加一个新的 img
元素,并为其指定 absolute
或 fixed
定位,以及高 z-index
。
下面是一个使用 fixed
定位将 SO Logo 添加到窗口 Angular 落的示例:
javascript:(function(){document.body.innerHTML += '<img src="http://sstatic.net/so/img/logo.png" style="position: fixed; left: 10px; bottom: 10px; z-index: 1000">';})();
关于javascript - Javascript 书签可以覆盖网页上的图像吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2480073/