CSS image loading test

Source: Internet
Author: User

Test when a CSS slice is loaded.

Test conclusion

The following style images are loaded when the page is loaded.

Embedded Style<Div style = "background-image: URL (image. aspx? From = page); ">

Embedded style sheet. Divcur {background-image: URL (image. aspx? From = style1 );}

If two

. Divcur {background-image: URL (image. aspx? From = style1 );}
. Divcur {background-image: URL (image. aspx? From = style2 );}

Then only the second image will be loaded.

External style sheet<Link href = "stylesheet.css" rel = "stylesheet" type = "text/CSS"/>Available Style

The following style is triggered under Different Conditions

Use js to modify the style and then load the image.

<Input type = "button" value = "JS modify style" onclick = "document. getelementbyid ('div1 '). style. backgroundimage = 'url (image. aspx? From = JS) '; "/>

Use js to modify the ID. The ID corresponds to the style to take effect.

# Body1 {background-image: URL (image. aspx? From = idstyle );}
<Input type = "button" value = "set body id" onclick = "document. Body. ID = 'body1';"/>

When. Divtest: hover {background-image: URL (image. aspx? From = hover );}Image loading only when hover is triggered

LikewiseA: active {background-image: URL (image. aspx? From = aactive );}Load images when you click

After the image is loaded, use<Input type = "button" value = "JS setting IMG" onclick = "document. getelementbyid ('img1'). src = 'image. aspx? From = page'; "/>

It is not triggered when the same image is loaded again.

Use JS embedded style on the page

<Input type = "button" value = "output page A: active style" onclick = "loadstyle ();"/>

Function loadstyle ()
{
VaR divstyle = Document. getelementbyid ('divstyle ');
VaR style = '. <style type = "text/CSS"> A: Active {background-image: URL (image. aspx? From = htmlaactive) ;}</style> ';
Divstyle. innerhtml = style;
Alert (divstyle. innerhtml );
}

Note that the IE label must contain other characters outside the <style> </style> label. Style is valid.

Test Method

Set background-image: URL (image. aspx? From = xxx); when the request arrives at image. aspx, the background page is triggered. You will know who requested it.

test the Code as follows:

<! Doctype HTML> 

Test instance: http://files.cnblogs.com/zjfree/styleImgTest.rar

 

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.