How to remove the default basemap of a browser using js

Source: Internet
Author: User
Tags zen cart

How to remove the default basemap of a browser using js

This article describes how to remove the default basemap of a browser by js. Share it with you for your reference. The specific analysis is as follows:

When we design some webpages with many images, in order to enhance the user experience, we hope that there will be a loading animation effect when the image is loaded, rather than a blank space.

This problem was also encountered during the secondary development of zen cart. The following is my solution.

The homepage sets a default loading animation for the image and assigns an id to it,

For example, a function is used to complete the loading process.

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

Function addListener (element, type, expression, bubbling ){

Bubbling = bubbling | false;

If (window. addEventListener) {// Standard

Element. addEventListener (type, expression, bubbling );

Return true;

}

Else if (window. attachEvent) {// IE

Element. attachEvent ('on' + type, expression );

Return true;

}

Else return false;

}

Var ImageLoader = function (url ){

This. url = url;

This. image = null;

This. loadEvent = null;

};

ImageLoader. prototype = {

Load: function (){

This. image = document. createElement_x ('img ');

Var url = this. url;

Var image = this. image;

Var loadEvent = this. loadEvent;

AddListener (this. image, 'load', function (e ){

If (loadEvent! = Null ){

LoadEvent (url, image );

}

}, False );

This. image. src = this. url;

},

GetImage: function (){

Return this. image;

}

};

Function loadImage (objId, urls ){

Var loader = new ImageLoader (urls );

Loader. loadEvent = function (url ){

Obj = document. getElementByIdx_x (objId );

Obj. src = url;

}

Loader. load ();

}

You can use the loadImage function to add a loading process for the specified image. The addListener function is used to register the event,

This allows you to automatically replace loading.gif with the animated transition image when the image preparation is complete. Easy to use code

?

1

2

3

4

<Script language = "javascript">

LoadImage ("loading1." http://www.baidu.com/img/baidu_logo.gif ");

</Script>

I hope this article will help you design javascript programs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.