Want to create a wrapper for code that detects presence of IE or Netscape

M

Matthew

Hello - I have this DHTML calendar that displays about 10 pixels off
its target in Netscape 7.0 -- from the script layer I have the block
of code identified that positions the calender on the screen. I was
thinking if I could write a wrapper around this that would execute two
different versions depending on which browser is coming in... for now
I am only interested in all versions of IE and NS 7.0 (haven't tested
it on earlier versions of NS, but would like to understand the flag
adjustments). Thanks for anyone's help!! :)
 
K

kaeli

Hello - I have this DHTML calendar that displays about 10 pixels off
its target in Netscape 7.0 -- from the script layer I have the block
of code identified that positions the calender on the screen. I was
thinking if I could write a wrapper around this that would execute two
different versions depending on which browser is coming in... for now
I am only interested in all versions of IE and NS 7.0 (haven't tested
it on earlier versions of NS, but would like to understand the flag
adjustments). Thanks for anyone's help!! :)

I've had similar problems with pixels. I stopped using them.

As a workaround and only if only IE and NN7 are the only browsers, the
following will work. (note: opera supports document.all)

if (document.all)
{
// IE
}
else
{
NN
}

HTH
 
L

Lasse Reichstein Nielsen

kaeli said:
As a workaround and only if only IE and NN7 are the only browsers, the
following will work. (note: opera supports document.all)

Some versions of Opera. Some of them only sometimes. And so several
other browsers too.
if (document.all)
{
// IE

Bad idea. As you say, it works if the *only* browsers they will view
the page are the *currently avilable* versions of IE and Mozilla.

Most other current browsers, and potentially a lot of future browsers,
will fail. So, don't go there, it's bound to come back and bite you in
the posterior.

The best way (IMNSHO[1]) is to
1) Use a doctype that triggers standards mode. That will let IE 6 show
the page according to the CSS 1 standard, instead of being bugwards
compatible with the highly deprected IE 4. In most cases, IE 6 and
Mozilla (and Opera and other standards supporting browsers) will then
show the pages identically.

I would use HTML 4.01 with en URL. Read more:
<URL:http://msdn.microsoft.com/library/en-us/dnie60/html/cssenhancements.asp>
<URL:http://mozilla.org/docs/web-developer/quirks/doctypes.html>
<URL:http://www.opera.com/docs/specs/doctype/>

2) Where the browsers still differ in rendering, make the page so that
it looks correct in Mozilla. Then add the changes needed to make it
look the same in IE, but wrap them in IE's conditional comments:
<!--[if IE]> blah blah fixes IE blah <![end if]-->
To all other browsers, it looks like a comment. To IE 5+, it is treated
as normal content.

<URL:http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp>

Normally, those two steps will be enough to fix any problems you might
have with IE.

/L
[1] in my, not so humble, opinion.
 
K

kaeli

[email protected] enlightened us said:
2) Where the browsers still differ in rendering, make the page so that
it looks correct in Mozilla. Then add the changes needed to make it
look the same in IE, but wrap them in IE's conditional comments:
<!--[if IE]> blah blah fixes IE blah <![end if]-->
To all other browsers, it looks like a comment. To IE 5+, it is treated
as normal content.

<URL:http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp>

That is SO cool. :)

Thanks for sharing.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top