简体   繁体   English

html,css,从gif文件执行javascript

[英]html, css, execute javascript from a gif file

I would like to know if it's possible to execute javascript from embedded .gif file . 我想知道是否可以从嵌入式.gif文件执行javascript。 I can make rewrite to a php file to seem as a gif file and execute the code from there but I'm not faimilar with css/html therefore I was wondering if there is any trick to make seem there is embedded a picture but to execute javascript . 我可以重写为php文件,看起来像是gif文件,然后从那里执行代码,但是我对css / html不太熟悉,因此我想知道是否有任何技巧可以使似乎嵌入了图片但可以执行javascript。 I tried img src attribute but is not working as the browser seems to consider it just a simple picture... 我尝试了img src属性,但由于浏览器似乎认为它只是一张简单的图片而无法正常工作...

GIF compression is lossy and is not suitable for code. GIF压缩有损,不适合代码。 However, the javascript hacker Jacob Seidelin implemented something very similar using pngs: http://blog.nihilogic.dk/2008/05/compression-using-canvas-and-png.html 但是,JavaScript黑客Jacob Seidelin使用png实现了一些非常相似的东西: http : //blog.nihilogic.dk/2008/05/compression-using-canvas-and-png.html

Not directly answering your question, but you can embed JavaScript into SVG. 您可以直接将JavaScript嵌入SVG,而不必直接回答您的问题。 Although not most browsers support SVG, but most SVG viewers support JavaScript. 虽然不是大多数浏览器都支持SVG,但是大多数SVG查看器都支持JavaScript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM