您的位置:首页 > 其它

如何用xml進行相關信息排序及添加右擊事件

2006-02-10 18:33 525 查看
在你的xsl文件中insert入下面code就可以了!
..............................................................................................................
<xsl:sort select="@date"></xsl:sort>--此為以xml文件中的日期為准
<xsl:attribute name="oncontextmenu"><!--單擊右鍵功能-->
window.event.cancelBubble = true;loadContextMenu('context.xml',
'<xsl:value-of select="@Staff_id"></xsl:value-of>',
'<xsl:value-of select="name"></xsl:value-of>');return false;
</xsl:attribute>
其中loadContextMenu是顯示右擊事個開啟頁面,暫時不做說明重點!
下面是一個例子:
<xsl:template match="guestbook">
<html>
<body bgcolor="#CCCC66" onselectstart="return false">
<center><h1>留言版</h1></center>
<table border="1" width="100%" bgcolor="#bbCCCC">
<tr bgcolor="#0099CC">
<td>最新留言||
<a href="../index.html">我要留言</a>
</td>
</tr>
<tr>
<table width="100%" border="1">
<xsl:for-each select="book">
<xsl:sort select="@date"></xsl:sort>
<tr bgcolor="#bbCC00">
<td rowspan="2" width="20%">
留言人:<xsl:value-of select="name"></xsl:value-of><p/>
來自:<xsl:value-of select="adress"></xsl:value-of>
</td>
<td width="80%">
留言時間:<xsl:value-of select="@date"></xsl:value-of>||
Email:<xsl:value-of select="email"></xsl:value-of>||
個人主頁:<xsl:value-of select="homepage"></xsl:value-of>
</td>
</tr>
<tr >
<xsl:attribute name="ONCLICK">alert("呵呵,原來是這樣呀!");</xsl:attribute>
<xsl:attribute name="oncontextmenu"><!--單擊右鍵功能,且cancelBubble是不讓顯示上下菜單的作用-->
window.event.cancelBubble = true;check_log();loadContextMenu('context.xml','<xsl:value-of select="@Staff_id"></xsl:value-of>','<xsl:value-of select="name"></xsl:value-of>');return false;
</xsl:attribute>
<td width="72%">
<xsl:choose>
<xsl:when test="position()=last()">
<a><xsl:attribute name="title">
這是最後一畢
</xsl:attribute>
<pre><xsl:value-of select="message"></xsl:value-of></pre>
</a>
</xsl:when>
<xsl:otherwise>
<pre><xsl:value-of select="message"></xsl:value-of></pre>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</tr>
</table>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: