The text swapping is taking place on subpages like this one:
http://elainemjohnston.mysite.freeserve.com/prop.html
(The main page is just using dreamweaver functions to swap an image of text.)
On the subpages when onmousedown occurs over the horizontal thumbnails a function is called that changes the innerHTML of a div with the id "caption" that is being used as a container.
function changeCaption(text, className) {
if(document.getElementById) {
document.getElementById("caption").innerHTML=text;
document.getElementById("caption").className=className;
}
}
- function changeCaption(text, className) {
- if(document.getElementById) {
- document.getElementById("caption").innerHTML=text;
- document.getElementById("caption").className=className;
- }
- }
The changing of className was discarded because it didn't suit cerio's needs and the second argument is being passed as an empty string. The div itself has no longer has a css class applied to it, so I don't think that's what causes the text to change position. Also I didn't experience the problem when I tested it. so I think the problem is most likely related to the html that is being passed to the function.
I'm not sure why escape characters are being mixed with regular html tags like in this example:
onMouseDown="changeCaption('<h1 class=redhead> Props <br/><br/><br/><br/></h1><p class=class3> Don Giovanni <br/><br/> Scottish Opera<br/> <br/> <br/><br/></p><p class=class2> Bed on lowering trap\, <br/> with pyrotechnics </p>','')
The only thing you need to escape is quotation marks that would break the function call and as LazyJim pointed out you can do that by placing a backslash before the quotes.
I also noticed the use of linebreaks (<br>) inside h1 tags to create spacing. Rather than putting linebreaks inside the h1 tag I think it would be better to apply a css class to the h1's that appear inside the caption div and use margin-bottom to create the spacing.
I also noticed that <br/> tags are being used which is technically incorrect because there should be a space between the r and the forward slash, i. e. <br />. I'm not sure what ramifications that has but since regular <br> is being used as well and the document does not appear to be intended to conform to xhtml I would just use the plain <br> tag.
I think that if the string of html being passed to the function is cleaned up and css is used to create your spacing that the problems with text shifting will go away. It looks like mozilla is ignoring at least one of the line breaks after the swapping occurs - although I'm really not certain why.
As far as passing a link I think you should be able to do that just by passing the
a tag and escaping the quotes in the manner that LazyJim recommended.