2010-04-24 46 views
0

其实我的代码---在最后添加列表内容?

function addElement(url,imagePath){ 
alert(url); 

alert(imagePath); 

var container = document.getElementById('sncs'); 


var new_element = document.createElement('li'); 

new_element.innerHTML ="<a href='#'><img src='"+imagePath+"' alt='' title='' width='466' height='165' onClick=\"javascript:addWidget('"+url+"')\"></a>"; 
new_element.className="jcarousel-item jcarousel-item-horizontal jcarousel-item-4 jcarousel-item-4-horizontal"; 
container.insertBefore(new_element, container.firstChild); 
} 
function addWidget(url) { 
    alert(url); 
    // var url='http://www.boxyourtvtrial.com/songs/public/'; 
    var main= document.getElementById('mainwidget'); 
    main.innerHTML = "<iframe src='"+url+"' align='left' height='1060px' width='576px' scrolling='no' frameborder='0' id='lodex'></iframe>"; 
} 

但是当我们添加图像itsnot在持续,但前面是怎么回事...... 所以请provid解决

回答

1

尝试使用

container.appendChild(new_element);

,而不是

container.insertBefore(new_element, container.firstChild)

+0

谢谢你,但 如果你要去的网页就像 http://www.boxyourtvtrial.com/demo/ U将在底部小窗口链接 看看是否点击它就会滚动菜单 我甲肝代码中添加元素最后,但当我addee我得到的图像在底部.... 请提供解决方案.... – rajesh 2010-04-24 10:06:45