一、创建html页面 demo.html
var value = dom.getElementsByTagName("News")[i].textContent.split(' ');
var title = value[4];
var content = value[8];
var date = value[12];
data.push({title:title,content:content,date:date}); //在这里,我们使用使用json,把数据库存储在里面
}
}
}
else
{
window.alert("dom对象为空,失败了!");
return;
}
if(data.length != 0)
{
var shtml = '';
for(var i=0;i<data.length;i++)
{
shtml += '<div>';
shtml += '<div style="float:left; background-color:Red; width:80px; height:15px">';
shtml += data[i].title;
shtml += '</div>';
shtml += '<div>';
shtml += '<div style="float:left; background-color:Green;width:150px; height:15px">';
shtml += data[i].content;
shtml += '</div>';
shtml += '<div style="float:left; background-color:Green;width:120px; height:15px">';
shtml += data[i].date;
shtml += '</div>';
shtml += '</div>';
shtml += '</div>';
shtml += '<br/>';
}
document.getElementById('textDiv').innerHTML = shtml;
}
else
{
document.getElementById('textDiv').innerHTML = '没有信息!';
}
}
</script>