PDA

View Full Version : Urgent!!! AjaxTabs+overrideMimeType not work in IE



liyenn
08-13-2007, 09:56 AM
1) Script Title: AjaxTabs

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/

3) Describe problem:

Hi, i'm displaying page with the encoding - GBK in my ajaxtabs <div>s.

I added script like :

======================================================
page_request = new XMLHttpRequest()
if (page_request.overrideMimeType) {
page_request.overrideMimeType('text/xml; charset=GBK');
}
======================================================

However, it only works in FireFox.

The content appear as "?????" in IE.

What can i do to solve this problem???

Thank you!

jscheuer1
08-13-2007, 02:27 PM
IE doesn't have:


overrideMimeType()

The only alternative I have seen offered that seems to work with consistency is to make sure that both the top page and the external page are served with the proper encoding. There are various ways to do this, the best ones are done on the server side.

See "5.2.2 Specifying the character encoding (http://www.w3.org/TR/html4/charset.html#h-5.2.2)" on:

http://www.w3.org/TR/html4/charset.html

liyenn
08-13-2007, 03:31 PM
IE doesn't have:


overrideMimeType()

The only alternative I have seen offered that seems to work with consistency is to make sure that both the top page and the external page are served with the proper encoding. There are various ways to do this, the best ones are done on the server side.

See "5.2.2 Specifying the character encoding (http://www.w3.org/TR/html4/charset.html#h-5.2.2)" on:

http://www.w3.org/TR/html4/charset.html

thanks for your reminder..
however, i'm hving difficulty accessing the link you mentioned above...
can i have the link again?

thanks!

jscheuer1
08-13-2007, 03:39 PM
http://www.w3.org/TR/html4/charset.html#h-5.2.2

Worked fine here, but I seem to have to refresh the page to get it to scroll to the named anchor.

liyenn
08-13-2007, 03:56 PM
jscheuer1,

just like to confirm...

the most possible reason the page not shown properly is cause by the encoding problem.

so if the main page encoding is GBK, for the external link, it should contained everything like below..


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=GBK">
</head>

<body>
the content of the page

</body>
</html>

am i right?

actually, i also tried to remove the red fonts (mentioned in my 1st post) and do something like this here:

if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset:GBK");
page_request.overrideMimeType("text/html; charset=GBK");
page_request.send(null)

it works fine in Firefox, but in IE, it only display the status of "loading..." it can't get to display the content of the page...

jscheuer1
08-13-2007, 04:45 PM
You have the right idea, but the wrong approach. As I said,

overrideMimeType()

doesn't exist in IE. At best, it will be undefined. The way you now seem to have it, I think it might cause an error in IE. Don't use overrideMimeType() for this. In fact, the script itself shouldn't be changed in the first place.

You need to control the mime type character set header that the page is served with. You may be able to do so with meta tags on both the top and external pages, this will work with some servers. To really control the mime type character set header that your pages are served with, you need to configure your server. I'm not really experienced with how to do that (there are several ways and these can vary by server, as well as your access to it), but I did provide a link to information on how to do so. Your host may be a resource for you in this, it depends upon what type of host it is and what kind of support they offer.

There are also other resources around the web you can find via Google or your favorite search engine that detail how to configure the server's mime type character set header, if your host allows and supports any of the possible methods.