Core
ACTIVE

INITIALIZING..._

STATUS: ONLINE
Mem Usage: 20%
SECTION: LOG
READING_LOG // 简单粗暴的实现更好的博客图片预览
DECRYPTING_STREAM...

简单粗暴的实现更好的博客图片预览

Auth: Rinth[X] Type: 编程

我的博客一直缺一个图片预览功能,我显然是想把它做的很好,但是我没有那么多闲时间去写、测试了。
当然,我用ci写的那坨使里面有现成的代码可以搬,为什么不用呢?~因为我懒~
呃,就是那坨使,之所以叫使是有原因的。
所以我用了简单的步骤,解决了图片不能预览的问题:

                function openWindow(url,name) {
                const specs = "width=1200,height=800";
                window.open(url, name, specs);
                }
                const articlesection = document.getElementById('articleO');
                articlesection.addEventListener('click', (event) => {
                        const target = event.target;
                        if (target.tagName === 'IMG'){
                                const src = target.src;
                                const alt = target.alt;
                                openWindow(src,alt);
                        }
                });

之后,我在<article>添加了id='articleO',然后上线了。
为什么叫articleO?因为我瞎打的;为什么加O?我怕以后跟某个功能的id冲突,总之就是这样。
你可以用下面这张图片试试效果:

IMG:TEST

[ END_OF_FILE :: CONNECTION_CLOSED ]
< Terminal
Comm_Link_Signal