louisremi / background-size-polyfill

Adds support for background-size "cover" and "contain" to IE8
http://louisremi.github.com/background-size-polyfill/
MIT License
1.26k stars 359 forks source link

Is this really work in IE8 just with adding -ms-behavior? #54

Open Metafalica opened 10 years ago

Metafalica commented 10 years ago

First of all, I think - when you giving example, it should be minimal, so everyone can understand what he need to make it work.

Your index.html is visually good, but not that good at explaining what I need to do to make it work. So, I followed your instruction and created this simplest code: Err, I don't know how to paste code here, since [code] no work and html disappears. Look code here: http://stackoverflow.com/questions/25338009/background-size-polyfill-does-not-work-in-ie8

I made this minimal test page and background-size: contain and cover completely no work. In IE8 background acts the same way as without this thing.

tigt commented 10 years ago

I left an answer on StackOverflow as well, but I'll answer here for posterity.

You need to place the .htaccess file inside a running Apache server. You have it placed on your Windows desktop for your local testing, so it doesn't get served at all, which precludes the requirement "served with the correct MIME type."

If you're using server software other than Apache, you don't need to include .htaccess; the server will automatically take care of that for you.

Metafalica commented 10 years ago

But... index.html that comes in package works in that way! I also viewing it from folder by double clicking the page without any servers.

tigt commented 10 years ago

Yeah. Frustratingly inconsistent, isn't it?

Metafalica commented 10 years ago

I don't understand what you means. If index.html page works fine in IE8 without any servers, why my page no work as expected? What I ask is what else I must do to make it work.

jefferyto commented 10 years ago

Does your file have a standards mode DOCTYPE?

<!DOCTYPE html>

The polyfill doesn't work in quirks mode (this is a known issue).

Metafalica commented 10 years ago

Oh it started working... Thank you. However, I think it would be good to add this into instructions where is said about adding -ms-behavior.

jefferyto commented 10 years ago

Good to hear :-) Thanks for your suggestion - I'll add it to the Readme.

(Also thanks @tigt - having a proper localhost is IMHO best practice.)

Metafalica commented 10 years ago

You have any ideas why it no work in quirks mode? Actually, I use quirks on purpose to avoid table height calculation bug in IE8 - 10. I though maybe I can make a fix for quirks mode.

jefferyto commented 10 years ago

I'm not sure why it doesn't work in quirks mode. (I'm afraid I don't have enough free time at the moment to investigate.) I would consider any fix to be for existing sites that can't convert to standards mode; every new project should really use standards mode. There will be bugs in IE either way ;-)

Metafalica commented 10 years ago

Maybe you can tell me how to debug htc? Line by line execution and viewing variables data.

jefferyto commented 10 years ago

This should help: http://msdn.microsoft.com/en-us/library/dd565628(v=vs.85).aspx

Metafalica commented 10 years ago

Ok thank you very much. I will see what I can do.

Metafalica commented 10 years ago

Looks like I found why it no work in quirks, but I don't know why that happens. In quirks the code in htc is not executed at all. I tried adding alert('asd'); right after script opening tag, but it alerts with doctype only. I will try to redo all this into *.js file

tigt commented 10 years ago

According to this http://msdn.microsoft.com/en-us/library/ie/ms530723(v=vs.85).aspx, when IE8 isn't in Standards mode, -ms-behavior is just called behavior. Does that work?

Metafalica commented 10 years ago

Well... for some really weird reason the background simply disappears. But at least code in htc executed.

tigt commented 10 years ago

I fear there might be methods in the .htc that IE8 doesn't support in Quirks Mode. Without a JavaScript console in IE8, that would be very hard to fix.

Plaristote commented 9 years ago

Hm. Interesting. I have the same issue than you Metafalica. The code is executed (I had to use behavior instead of -ms-behavior though), and the background simply disappeared. Did you ever find out what was happening ?

I also made sure that I wasn't in quirk mode, using this piece of code: mode = (document.compatMode=='CSS1Compat'?'Standards':'Quirks')