So when the line is very long, IE seems to wrap it thus creating an unterminated string error in javascript.
How long is long? Line length doesn't matter much to IE. If you're getting unterminated strings, chances are that the problem is either in your code, or in the "long message" you're using in the onmouseover(). Perhaps that string has embedded quotes that aren't being properly escaped.
Show us one of these broken long lines, and the code that generated it.
| [reply] |
The odds are that it isn't the length per se, but rather that there is a character in the long lines which affects the parsing.
In any case you can use HTML::Entities and call encode_entities($javascript, "\\W") to get a version of the string to stick in the URL which should be protected from both line-breaks and unexpected interpretation of input characters. | [reply] [d/l] |
Using HTML::Entities, as the above Annymous Monk mentioned, would be a good bet. However, if that doesn't work for you, you can break up long lines of text in JavaScript like so:
var textmsg = "This is a long line of text that just " +
"seems to keep on going and going and " +
"is just particularly large.";
<a href='some.site.com/address' onmouseover='popup(textmsg)'
onmouseout='hidepopup()'> nameoffile.p
+df</a>
If the problem really is with the length of your line, breaking it up like so should fix that.
As a side note, are you sure you want to pop up a message whenever somebody puts their mouse over a link? Many might find that somewhat undesirable.. perhaps having the file description as text under the link, or even using image rollovers might work.
Browsers are beginning to offer functionality to block unrequested popup windows. I'm not sure whats considered "unrequested", but you may wish to test that out before your customers start complaining that they don't see any file descriptions :-)
Good luck!
-Eric
--
Lucy: "What happens if you practice the piano for 20 years and then end up not being rich and famous?"
Schroeder: "The joy is in the playing." | [reply] [d/l] |
Along the lines of "don't roll your own" and "don't reinvent the wheel," instead of Javascript, you could use the HTML attribute that is already defined to provide just the functionality you're trying to replicate: namely, the title attribute (and not alt, which is a whole 'nother beast, though Internet Explorer thinks otherwise). So,
<a href="example.com" title="This is my title. There are many like it, but this one is mine. My title is my best friend. It is my life. I must master it as I master my life.">
BCE --You'reYour culture will adapt to service our'sours.
| [reply] [d/l] [select] |
Ah, urethra!
Thank you for the enlightenment. I couldn't see the forest for the trees!
I simply used
$longmessage =~ s/\s/ /g;
There must be some kind of endline character somewhere.
And all is well!
Thanks, again
Cliff | [reply] [d/l] |