The majority of XML Donews blog templates do not display the latest article List of features, the following is the use of XMLHTTP technology to achieve this function of the idea and code, the effect of the left side of the "latest article" column. Because Donews blog and discuz Forum, the different templates are each, can not give a unified variable name (HTML tag ID value), so need to be in the code based on CSS modified to produce the appropriate effect.
Ideas and technical background
The idea is very simple, directly with XMLHTTP Read Blog RSS file, take out the latest article inserted in advance prepared HTML tag can.
XMLHTTP is the technology that Microsoft invented in the last century for its own web apps, which the big speakers gave a new name, Ajax, to compliment Google on several web apps, but threw Microsoft aside. As Microsoft, Firefox and Opera integrate XMLHTTP into their respective browsers, Web developers do not need to let users download ActiveX, simply call them with a favorite Web script, and Ajax effects begin to spread.
Raw Code
<ul class= "list" id= "My_last_post" ></ul><ul class= "list" ><li>
<script type= "Text/javascript" ><!--
var xmlhttp = false;
function Load_rss ()
{
XMLHTTP = false;
if (window. XMLHttpRequest)
{
XMLHTTP = new XMLHttpRequest ();
if (Xmlhttp.overridemimetype)
{
Xmlhttp.overridemimetype (' Text/xml ');
}
}
else if (window. ActiveXObject)
{
Try
{
XMLHTTP = new ActiveXObject ("Msxml2.xmlhttp");
}
catch (E)
{
Try
{
XMLHTTP = new ActiveXObject ("Microsoft.XMLHTTP");
}
catch (E)
{
}
}
}
if (!xmlhttp)
{
Return
}
Xmlhttp.onreadystatechange = Proc_rss;
Xmlhttp.open (' Get ', '/concorde/rss.aspx ', true);
Xmlhttp.send (NULL);
}
function Proc_rss ()
{
if (xmlhttp.readystate = 4)
{
if (Xmlhttp.status = 200)
{
var items = xmlhttp.responseXML.getElementsByTagName (' item ');
var L = 6;
if (Items.length < 6)
{
L = items.length;
}
var html = ';
for (var i = 0; i < L; i++)
{
html = html + get_item (items, i);
}
var obj = document.getElementById (' my_last_post ');
if (obj)
{
obj.innerhtml = html;
}
}
}
}
function get_item (items, IDS)
{
var link = items[id].getelementsbytagname (' link '). Item (0). Firstchild.nodevalue;
var title = Items[id].getelementsbytagname (' title '). Item (0). Firstchild.nodevalue;
var item = ' <li class= ' listitem ' ><a href= ' + link + ' > ' + title + ' </a></li> ';
return item;
}
Load_rss ();
File://-->
</script>
The second line of code has an open <ul class= "list" ><li>, which is used to close the following code (written in the template of the Donews blog); '/concorde/rss.aspx ' in the code You need to modify the RSS feed for yourself or someone else (but you cannot use XML other than the blog.donews.com domain name, such as Feedbunrer); finally put the code in the "options» Configuration» Bulletin" where it fits. To decorate the display, you may need to match the appropriate CSS code. It is also recommended that you add:. Listitem{word-wrap:break-word;overflow:hidden in custom CSS styles This prevents comments in IE to support large pages, in Firefox is hidden overflow text.