Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if IE then die 1

Status
Not open for further replies.

simon551

IS-IT--Management
May 4, 2005
249
Hi. I'm working on an intranet site so I have the luxury to be lazy and not test in IE. We have a corporate policy to only use firefox. But I have found that people use it anyway out of old habits. Instead of testing in IE, to save time (single programmer not all that skilled) I'd like to just put in a script in my first included file that test for browser and if not firefox or safari then die.
Second part about being a fairly limited programmer (actually I'm an accountant who does some programming but I digress): I can't figure this out. I tried modify some basic AJAX browser testing to just determine if this is not firefox/safari/opera but it's not working. Can you check what I'm doing?
Code:
<script type="text/javascript">
function browserCheck()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
      alert("Do not use IE, sorry!");
  }
}
  window.onload=browserCheck;
</script>
Thanks!
 
How about using a conditional comment to solve this:
Code:
<html>
<head><title>Sample</title>
[!]<!--[if IE]>[/!]
<script type="text/javascript">
  alert('You need to use the corporate approved browser to view this page');
</script>
[!]<![endif]-->[/!]
</head>
<body>
[!]<!--[if ! IE]><!-->[/!]

<h1>This is never rendered by IE for windows</h1>
<p>Place your page contents here.</p>

[!]<!--<![endif]-->[/!]
</body>
</html>

This will pop up an alert message (so there is some element of javascript to this solution) and also prevent the page contents from showing for IE for windows.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top