Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2012, 11:06 AM   PM User | #1
Junsee
New Coder

 
Join Date: Jun 2012
Posts: 42
Thanks: 4
Thanked 5 Times in 5 Posts
Junsee is an unknown quantity at this point
Opera Browser - Mouse over issue

I have some js code (not my own as I am really lacking in java knowledge)

PHP Code:
<script>
    function 
showtarget(which) {
        var 
spans document.getElementById("MenuDescription").getElementsByTagName("SPAN");
        for ( var 
0<= spans.length; ++) {
            
spans[s].style.display = ( == which-1) ? "inline" "none";
        }
    }
</script> 
You can see the site here http://www.stokerscoffeelounge.com.a...etpancakes.php
(Taking the example on Opera Browser, where you hover over Fresh Strawberry and then Spicy Apple)

Basically on the mouse over of the Menu Items, you find that is displays correctly on all browsers except one. On the Opera Browser, when you hover over Spicy Apple some of the Fresh Strawberry text is left over.

I don't want to clear the text on mouseout as that would be annoying to people as they would have keep their mouse trained on the menu item while reading the text on the right.

I need to know how to clear the element before it grabs the next span?

Much appreciation and thanks for comments, suggestions and fixes.

Last edited by Junsee; 12-04-2012 at 11:08 AM..
Junsee is offline   Reply With Quote
Old 12-04-2012, 07:13 PM   PM User | #2
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Quote:
Originally Posted by Junsee View Post
I have some js code (not my own as I am really lacking in java knowledge)
So is the author of that code.


Quote:
Code:
		for ( var s = 0; s <= spans.length; ++s ) {
Remove the '=' as it causes an addressing error, then see if it changes anything.
Logic Ali is offline   Reply With Quote
Old 12-04-2012, 10:43 PM   PM User | #3
Goos
New Coder

 
Join Date: Apr 2011
Posts: 45
Thanks: 0
Thanked 11 Times in 11 Posts
Goos is an unknown quantity at this point
You should validate your HTML aswell.
Having block-elements inside inline-elements is part of the problem.
Goos is offline   Reply With Quote
Old 12-05-2012, 01:09 AM   PM User | #4
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,448
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by Logic Ali View Post
So is the author of that code.
Not necessarily - the author of the code may be a Java expert - it is JavaScript knowledge that they are lacking.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 12-05-2012, 10:27 AM   PM User | #5
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Quote:
Originally Posted by felgall View Post
Not necessarily - the author of the code may be a Java expert - it is JavaScript knowledge that they are lacking.
The cause of the error in question would be just a easy to spot (and avoid) by a competent in either language.
Logic Ali is offline   Reply With Quote
Old 12-05-2012, 06:33 PM   PM User | #6
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,448
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by Logic Ali View Post
The cause of the error in question would be just a easy to spot (and avoid) by a competent in either language.
If that is true then why is all of Google's JavaScript code such an antiquated mess. They have a large number of Java experts working for them who would surely recognise that all their JavaScript is garbage if the two languages were similar enough for people working in one to spot errors in the other - particularly such huge errors as are made throughout Google's JavaScript code.

That surely is evidence that someone can be a Java Expert and know absolutely nothing at all about JavaScript. Or is all of Google's Java code as badly written as their JavaScript?
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/

Last edited by felgall; 12-05-2012 at 06:36 PM..
felgall is offline   Reply With Quote
Old 12-05-2012, 08:45 PM   PM User | #7
Junsee
New Coder

 
Join Date: Jun 2012
Posts: 42
Thanks: 4
Thanked 5 Times in 5 Posts
Junsee is an unknown quantity at this point
PHP Code:
for ( var 0spans.length; ++) { 
No that didn't work either, no change on Opera
and the other broswers (Which still work fine)

Thanks for all the help



EDIT: to further add
When I open DragonFly, Operas Debugging console, the Script works correctly!
As soon as I close the debugging console it goes back to leaving a shadow.
Weird

Last edited by Junsee; 12-05-2012 at 08:57 PM..
Junsee is offline   Reply With Quote
Old 12-06-2012, 03:18 AM   PM User | #8
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Quote:
Originally Posted by Junsee View Post
PHP Code:
for ( var 0spans.length; ++) { 
No that didn't work either, no change on Opera
and the other broswers (Which still work fine)
To give a clean starting point for analysing the problem, you should update the online site to reflect the changes, including validated markup.
Logic Ali is offline   Reply With Quote
Old 12-06-2012, 03:31 AM   PM User | #9
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Quote:
Originally Posted by felgall View Post
If that is true then why is all of Google's JavaScript code such an antiquated mess.
I cited a for loop ranging error in isolation, which I maintain a programmer of either language would not have made, or at worst would have spotted it immediately.

Quote:
They have a large number of Java experts working for them who would surely recognise that all their JavaScript is garbage if the two languages were similar enough for people working in one to spot errors in the other
Whether or not that would happen, doesn't dictate that in practice any remedial action would follow.
Logic Ali is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:48 AM.


Advertisement
Log in to turn off these ads.