Because the second image is downloaded from the server at the time the user rools over the first image, there can be a perceptible delay before the second image replaces the first one, especially for people browsing your site with a slower connection.
  • Using this method causes an error message in ancient browsers, such as Netscape 2.0 or earlier, Internet Explorer 3.0 or earlier, or the America Online 2.7 browser. Since there are so few of these vintage browsers still in use, it's not much of a problem these days.
  • ">
    立诚勿怠,格物致知
    It's all about connecting the dots

    Simplest Image Rollovers Effect Created by JavaScript

    Code presented firstly, haha.

    
    
    
        A Simple Rollover
        
    
    
        arrow
    
    
    

    The above small code snippet is very simple, but with some problems and drawbacks:

    • Because the second image is downloaded from the server at the time the user rools over the first image, there can be a perceptible delay before the second image replaces the first one, especially for people browsing your site with a slower connection.
    • Using this method causes an error message in ancient browsers, such as Netscape 2.0 or earlier, Internet Explorer 3.0 or earlier, or the America Online 2.7 browser. Since there are so few of these vintage browsers still in use, it’s not much of a problem these days.

    To avoid the above problems and drawbacks, you can use the code snippets below (please be informed that now the javascript is separated from the HTML file):

    Here is the HTML code:

    
    
    
    
        A More Effective Rollover
        
        
    
    
        button1  
        button2
    
    
    

    And here is the corresponding JavaScript code related to the above HTML code:

    
    window.onload = rolloverInit;
    function rolloverInit() {
        for (var i=1; i

    Reference: JavaScript Visual QuickStart Guide (8th Edition)

    赞(0) 打赏
    版权声明:非商业用途转载请注明文章链接,商业用途转载请联系邮箱获取授权。
    文章名称:《Simplest Image Rollovers Effect Created by JavaScript》
    文章链接:https://www.orzzone.com/simplest-rollovers-created-by-javascript.html
    商业联系:yakima.public@gmail.com
    本站内容仅供个人学习交流,不做为任何投资、建议的参考依据,因此产生的问题需自行承担。

    评论 抢沙发

    大前端WordPress主题 更专业 更方便

    支持快讯、专题、百度收录推送、人机验证、多级分类筛选器,适用于垂直站点、科技博客、个人站,扁平化设计、简洁白色、超多功能配置、会员中心、直达链接、文章图片弹窗、自动缩略图等...

    去看看

    觉得文章有用就打赏一下文章作者

    非常感谢你的打赏,我们将继续给力提供更多优质内容!

    支付宝扫一扫打赏

    微信扫一扫打赏

    登录

    找回密码

    注册