JS functions in HTML not found

Hi guys,

i have one question for you. i currently try to program html + jS in a HTML macro.

i want to create a mouseOver Action when mouse goes over an image.

the code works in the preview, but when i press "Save" i got warnings the JS functions are not defined.

(MM_swapImmRestore(), MM_swapImage()).

Any idea what i made worng.

Thx for your help.

{html}
<html> <head>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>

<body onload="MM_preloadImages('http://kebwiki/download/attachments/57377183/Image1.png','http://kebwiki/download/attachments/57377183/Image2.png','http://kebwiki/download/attachments/57377183/Image3.png','http://kebwiki/download/attachments/57377183/Image4.png')">
<center>
<div id="keba_icons">
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image1','','http://kebwiki/download/attachments/57377183/Image1.png',1)"><img src="http://kebwiki/download/attachments/57377183/Image1_1.png" name="Image1" border="0" id="Image1" /></a>
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image2','','http://kebwiki/download/attachments/57377183/Image2.png',1)"><img src="http://kebwiki/download/attachments/57377183/Image2_1.png" name="Image2" border="0" id="Image2" /></a>
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','http://kebwiki/download/attachments/57377183/Image3.png',1)"><img src="http://kebwiki/download/attachments/57377183/Image3_1.png" name="Image3" border="0" id="Image3" /></a>
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','http://kebwiki/download/attachments/57377183/Image4.png',1)"><img src="http://kebwiki/download/attachments/57377183/Image4_1.png" name="Image4" border="0" id="Image4" /></a>
</div>
</center>
</body>
</html> {html}



1 answer

1 vote
David Simpson Community Champion Jul 02, 2013

This HTML is not valid. You can't nest a full HTML document inside another. Things are bound to break.

Also, rather than pasting some old-fashioned squirrel code that looks like it was generated by Dreamweaver, it would be nicer to write it afresh with modern HTML/CSS - it makes debugging somewhat easier.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Agile

What is ChatOps? A guide to its evolution, adoption, and significance

I am the product of AIM. I can hear that door swinging open and closed in my mind with absolute fidelity. I’d recognize that ding anywhere. At 15, as I typed away into AOL IM, I never imagined that ...

47 views 1 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you