By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!! :)
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <19**************************@posting.google.com >,
ma******@yahoo.com enlightened us with...
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

--
~kaeli~
I do whatever my Rice Krispies tell me to.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2

P: n/a
kaeli <ti******@NOSPAM.comcast.net> writes:
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.
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

P: n/a
In article <d6**********@hotpop.com>, lr*@hotpop.com enlightened us
with...

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.

--
--
~kaeli~
If a turtle doesn't have a shell, is he homeless or naked?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.