PDA

View Full Version : Javascript question.


Pie-rate
03-15-2005, 03:37 PM
I'm writing a Java program (don't run away yet, this IS a javaSCRIPT question) that converts a .java file to a .html file, with syntax coloring. I want it to change the status bar when you mouse over a line to say the line number you've mouseovered.
I've already done this using "<span onmouseover=\"window.status=\'Line: "+n+"\'\">", but you have to mouse over the TEXT on the line, which could cause confusion. For example if you mouse over an empty line it won't change the status bar.

So my question is how do you detect when someone has mouse overed an entire line, not just some text on the line?

I want to keep the size of the html used per line minimal, as a 1000 line bit of code with a 200 character html code on each line is an additional 100kb!!! (about +15sec download on my current connection)

Jon Hanlon
03-15-2005, 04:08 PM
How exactly are you determining 'line number' when the mouse is over a line of text?

Pie-rate
03-15-2005, 04:11 PM
Lets assume the line knows what line number it is.
Example, at the beginning of line 1 there's <span id="line1">
and so on.

Edited for minor typos - because you're worth it.

Jon Hanlon
03-15-2005, 04:16 PM
You could have nested spans:
<span style="width:100%" id="line1"><span>text goes here</span></span>

Pie-rate
03-15-2005, 04:31 PM
Ok I'll try it.

Oh why couldn't it just be
<span style="width:100%" id="line1">text</span>

RysChwith
03-16-2005, 07:12 AM
Could you wrap each line in a div, and put the mouseover on the div? I think you'd have to make sure that empty lines have a non-breaking space in them, but it seems like it'd work.

Rys