...

View Full Version : How do I explain... XMLHttpRequest?



Tyrial101
01-04-2007, 01:10 PM
Hi guys, this isn't a normal question but I am still hoping you can all help me out.


This is a code I have used for awhile, but I honestly don't know how it works, I just know it does.

I am loading 2 different CSS files with:



<!--
if (window.XMLHttpRequest)
{
document.write('<link rel="stylesheet" type="text/css" href="mainStyle.css" />')
}


else
{
document.write('<link rel="stylesheet" type="text/css" href="ieStyle.css" />')
}
//-->


How would I explain how the if statement if (window.XMLHttpRequest) works?

Spudhead
01-04-2007, 01:19 PM
In what context? It's object detection. You're looking to see if the current window object supports an XMLHttpRequest object.

A1ien51
01-04-2007, 02:10 PM
UM, someone used that to detect non IE browsers, but IE7 now supports that so it will use that style sheet probably breaking the changes.

I think you better find a new way to do CSS includes. A lot of people around here will say why bother having two when you can try to work in one? Normally a missing DOC-TYPE is the reason why IE is different.

Eric

Tyrial101
01-05-2007, 02:49 AM
It isn't a missing Doctype. My entire site is XHTML 1.0 Strict and It all validates, aswell as my code. But for some reason in IE 6 and below, added my padding to the width of a div instead of inserting the padding into the div.

So I basically made two CSS files that were generally the same, accept for that small detail, and one was for IE 6- and the other was for all other browsers including IE7


In what context? It's object detection. You're looking to see if the current window object supports an XMLHttpRequest object.

I know what the script does but what does XMLHttpRequest actually do? I tried googling it but I can't really understand most of the explainations. Something about sending XML through HTML?

It would probably help if I knew XML.

SpirtOfGrandeur
01-08-2007, 09:24 AM
The XMLHttpRequest object creates a call to the server. This call returns a page that you can use to update the page that made the call back to the server.

http://en.wikipedia.org/wiki/XMLHttpRequest

felgall
01-08-2007, 10:56 PM
You can do it using IE conditionals in your HTML and not require any Javascript at all. The following will override the main stylesheet settings with IE specific ones in IE6 and earlier regardless of whether Javascript is enabled or not.


<link rel="stylesheet" type="text/css" href="mainStyle.css" />
<!--[if IE lte 6]>
<link rel="stylesheet" type="text/css" href="ieStyle.css" />
<[endif]-->



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum