这个java脚本代码在Joomla中不起作用吗?如何更改图像标记中的源路径?
function changetxt(name){
var arr = new Array("btn1","btn2","btn3","btn4");
var pic = new Array("ban_txt.png","ban_txt1.png","ban_txt.png","ban_txt1.png");
var s="";
for(var i=0;i<arr.length;i++){
if(arr[i]==name){
document.getElementById(name).src="../../images/orange.png";
document.getElementById(name).src="../../images/"+pic[i];
}
else{
document.getElementById(arr[i]).src="../images/grey.png";}
}
答案 0 :(得分:0)
定义网站网址和管理网址,并将其与您的图片src一起使用。它肯定会对你有用。
function changetxt(name){
var adminurl = "<?php echo JURI::base(); ?>";
var siteurl = "<?php echo JURI::root(); ?>";
var arr = new Array("btn1","btn2","btn3","btn4");
var pic = new Array("ban_txt.png","ban_txt1.png","ban_txt.png","ban_txt1.png");
var s="";
for(var i=0;i`<`arr.length;i++){
if(arr[i]==name){
document.getElementById(name).src=adminurl+"images/orange.png";
document.getElementById(name).src=adminurl+"images/"+pic[i];
}
else{
document.getElementById(arr[i]).src=siteurl+"images/grey.png";}
}