Chrome says “Resource interpreted as script but transferred with MIME type text/plain.”, what gives?

后端 未结 20 2548
眼角桃花
眼角桃花 2020-11-22 07:21

In FF and all, my javascript works fine. But in Chrome it gives this message:

Resource interpreted as script but transferred with MIME type text/plai

20条回答
  •  执笔经年
    2020-11-22 08:06

    I was having the same issue when trying to change a background images in a array through javascript (jQuery in this case).

    Anyway.

    Instead of this:

    m.setStyle('background-image','url(/templates/site/images/style5/'+backgs[i]+')')
    

    do this:

    eval("m.setStyle('background-image','url(/templates/site/images/style5/'+backgs[i]+')')");
    

    Chrome javascript gets screwed when trying to parse a variable inside an element structured with ' . In my case it stopped just before the image array being inserted. Instead of parsing the image url + image name (inside the array), it was parsing just the image url.

    You probably need to search inside the code and see where it happens. FF, IE and all other don't have this problem.

提交回复
热议问题