简体   繁体   中英

In IE8, why is it that when I point a link to Twitter.com, it pops up a “download open/save as…” dialog?

<a href="http://twitter.com/theusername">Click</a>

For some reason, it pops up the download instead of going to the page.

Edit: When I close IE8 and open it again, it works again. Then, the 2nd time, it won't work. I have to close and open IE8 each time for it to work.

As already surmised, this problem is due to Twitter returning its mobile-targeted pages with Content-Type: application/xhtml+xml instead of the usual desktop-browser-targeted text/html . IE is infamous for being the browser that cannot handle application/xhtml+xml , so it's expected that it won't be able to access the mobile site properly.

The real problem is that Twitter is setting a session cookie ( _twitter_sess ) across all of twitter.com , and recording in your session whether you've ever attempted to access m.twitter.com before. If you have, all future access to [ www. ] twitter.com will be redirected to the mobile site. Goodness knows what that's supposed to achieve, but it nicely screws IE over, and it's amusingly exploitable in that if you can persuade an IE user to visit a page where you include content from m.twitter.com , you can break all their use of Twitter until they close the browser.

One would hope they'd fix it (and their inconsistent <meta> too whilst they're at it).

Proper answer:

As David and DN have said, the reason why IE is trying to download this is that it doesn't recognise application/xhtml+xml . Without a recognised content-type, it will normally fall back on extension, but as this URL contains no extension, it falls back to downloading as "Unknown File Type".


Old answer for posterity

That's a link to m.twitter.com, the mobile version. The data is being served as xhtml+xml , so I don't know why IE would try to download it.

Edit: There is no file extension (theusername isn't a directory with an index.htm in it, it's just a file). I think IE works out content type by extension, so if a file has no extension its type is "Unknown File Type", and it prompts to download.

Wow, that's odddd. Do you mean to be linking to the mobile site? I suspect there's some browser oddity there, on Twitter or IE8's side I'm not sure.

Following up on Skilldrick's reply, though, IE apparently still doesn't support application/xhtml+xml . That's very likely why--it doesn't support it, recognizes it's a file, and so asks you to download it.

I suspect it's because of the response header that Twitter is sending back. I'm not sure exactly what makes IE do that; there's a typo in the "Content-type" line, for one thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM