Problems with Opera

B

Bob Richardson

In http://www.writeonwhidbey.org/_private/ssi/ssitest.html I have a simple
function

<script language="JavaScript1.2" style="text/javascript">
<!--
function checkLocation() {
if (navigator.userAgent.indexOf("Opera")!=-1) type="OP"
else if (document.all) type="IE" // ie 4 & up
else type="XX"
if (type=="IE")
moveNav.style.pixelTop=document.documentElement.scrollTop
setTimeout("checkLocation()",5);
}
//-->
</script>

This is suppose to keep the Nav bar at the top of an IE browser. (Yes, it
wobbles a little bit, but what can I do?)

With most other browsers, the Nav Bar stays nice and stationary at the top,
thanks to a nice CSS solution. However, with Opera (at least Opera 7.54 that
I have) the nav bar wobbles a bit like I would expect it to in IE, but still
it gets hidden under most scrolling situations. What's the cure for Opera?

TIA

p/s/ I also tried:
if (navigator.userAgent.indexOf("Opera")!=-1
&& document.getElementById) type="OP";

but did the same thing.
 
M

Michael Winter

On 18/04/2005 18:30, Bob Richardson wrote:

[snip]
<script language="JavaScript1.2" style="text/javascript">

Specifying the language attribute is at best, redundant. Specifying
the language attribute as JavaScript1.2 can be positively dangerous as
far as reliable execution is concerned. Remove it.

Remove the SGML comment delimiters. They are unnecessary (have been
for years).

[snip]
if (type=="IE")

If you really want this executed by IE only, then use conditional
comments (either JScript, or HTML) to hide the code from other user
agents. It is far more reliable than browser detection. You can search
the MSDN Library (<URL:http://msdn.microsoft.com/>) for both.

[snip]

Mike
 
B

Bob Richardson

After reading up on Conditional Comments, it appeared that this coding would
work, allowing the JS to work only with IE 5 and up.

<!--[if IE gte 5]>
<SCRIPT LANGUAGE="Javascript">
function checkLocation() {
moveNav.style.pixelTop=document.documentElement.scrollTop
setTimeout("checkLocation()",5);
}
</SCRIPT>
<![endif]-->

Works for NS and Firefox. In IE 6 "<!-- ->" appears at the top of
the nav bar, and in Opera, the Nav bar scrolls up when you scroll down!!
What am I missing!


Michael Winter said:
On 18/04/2005 18:30, Bob Richardson wrote:

[snip]
<script language="JavaScript1.2" style="text/javascript">

Specifying the language attribute is at best, redundant. Specifying the
language attribute as JavaScript1.2 can be positively dangerous as far as
reliable execution is concerned. Remove it.

Remove the SGML comment delimiters. They are unnecessary (have been for
years).

[snip]
if (type=="IE")

If you really want this executed by IE only, then use conditional comments
(either JScript, or HTML) to hide the code from other user agents. It is
far more reliable than browser detection. You can search the MSDN Library
(<URL:http://msdn.microsoft.com/>) for both.

[snip]

Mike
 
B

Bob Richardson

I see I misplaced the gte. This coding still does not work. Opera sees it
and it appears that IE doesn't!!

<!--[if gte IE 5]>
<SCRIPT LANGUAGE="Javascript">
function checkLocation() {
moveNav.style.pixelTop=document.documentElement.scrollTop
setTimeout("checkLocation()",5­);
}
</SCRIPT>
<![endif]-->

Bob Richardson said:
After reading up on Conditional Comments, it appeared that this coding
would work, allowing the JS to work only with IE 5 and up.

<!--[if IE gte 5]>
<SCRIPT LANGUAGE="Javascript">
function checkLocation() {
moveNav.style.pixelTop=document.documentElement.scrollTop
setTimeout("checkLocation()",5);
}
</SCRIPT>
<![endif]-->

Works for NS and Firefox. In IE 6 "<!-- ->" appears at the top of
the nav bar, and in Opera, the Nav bar scrolls up when you scroll down!!
What am I missing!


Michael Winter said:
On 18/04/2005 18:30, Bob Richardson wrote:

[snip]
<script language="JavaScript1.2" style="text/javascript">

Specifying the language attribute is at best, redundant. Specifying the
language attribute as JavaScript1.2 can be positively dangerous as far as
reliable execution is concerned. Remove it.

Remove the SGML comment delimiters. They are unnecessary (have been for
years).

[snip]
if (type=="IE")

If you really want this executed by IE only, then use conditional
comments (either JScript, or HTML) to hide the code from other user
agents. It is far more reliable than browser detection. You can search
the MSDN Library (<URL:http://msdn.microsoft.com/>) for both.

[snip]

Mike
 
S

Stephen Chalmers

Bob Richardson said:
I see I misplaced the gte. This coding still does not work. Opera sees it
and it appears that IE doesn't!!

<!--[if gte IE 5]>
<SCRIPT LANGUAGE="Javascript">
function checkLocation() {
moveNav.style.pixelTop=document.documentElement.scrollTop
setTimeout("checkLocation()",5­);
}
</SCRIPT>
<![endif]-->

Opera 7.54 does not "see" this code as it is effectively within conventional
comments. If you enable error reporting, you will see this causes an error
when the non-existent function is called onload:

<body onLoad="checkLocation()">

Having said that, It appears that you have just trashed the code. Perhaps
for the best...
 

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

No members online now.

Forum statistics

Threads
473,797
Messages
2,569,648
Members
45,381
Latest member
TomasLnx34

Latest Threads

Top