posts - 6,  comments - 12,  trackbacks - 3
  2008年12月15日

 

下载ajaxRss阅读器源码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>JavaScript RSS 阅读器</title>
    
<meta http-equiv="Content-Type" content="text/html"; charset="gb2312" />
    
<style type="text/css">
        body
{font-family:verdana,arial,helvetica,sans-serif;font-size:10pt;}
        a
{color:#003399;}
        a:hover
{color:#ff9900;}
        #feedOutput
{border-style:solid;border-width:1px;width:50%;background-color:#fafad2;padding:1em;}
    
</style>
    
<script type="text/javascript">
        
function readRSS(feedURL){
            
var request;
            
try{
            
/* 创建XMLHttpRequest对象 */
                request 
= new XMLHttpRequest();
            }
catch(e){request = new ActiveXObject("Msxml2.XMLHTTP");}
            
try{
            
/* 如果本地文件要访问http URL */
                netscape.security.PrivilegeManager.enablePrivilege(
"UniversalBrowserRead");
            }
catch(e){}
            request.open(
"GET",feedURL,false);
            request.send(
null);
            
var feed=request.responseXML;
            
var itemList = feed.getElementsByTagName('item');
            
var numItems=itemList.length;
            
/* 为项目列表创建html */
            
var newULTag=document.createElement('ul');
            
for(var i=0;i<numItems;i++){
                
/* 创建一个新的项目列表 */
                
var newLITag=document.createElement('li');
                
/* 得到项目标题及其文本 */
                
var itemTitle = itemList[i].getElementsByTagName('title');
                
var newItemTitleTxt=document.createTextNode(itemTitle[0].firstChild.nodeValue);
                
/* 创建一个指向项目的连接 */
                
var itemURL = itemList[i].getElementsByTagName('link');
                
var newATag = document.createElement('a');
                newATag 
= document.createElement('a');
                newATag.href
=itemURL[0].firstChild.nodeValue;
                newATag.appendChild(newItemTitleTxt);
                
/* 获取项目描述 */
                
var itemDescription = itemList[i].getElementsByTagName('description');
                
var descriptionTxt = document.createTextNode(itemDescription[0].firstChild.nodeValue);
                
var newPTag = document.createElement('p');
                newPTag.appendChild(descriptionTxt);
                
/* 创建一个追加html */
                newLITag.appendChild(newATag);
                newLITag.appendChild(newPTag);
                newULTag.appendChild(newLITag);
            }
            document.getElementById(
'feedOutput').appendChild(newULTag);
        }
    
</script>
</head>
<body>
    
<h1 align="center">简单Javascript制作的RSS阅读器</h1>
    
<h2 align="center"><href="http://www.docin.com/p-3620097.html">Ajax.net实现的动态输入项</a></h2>
    
<form name="feedForm" id="feedForm" method="get" action="#" runat="server">
    
<b>RSS Feed URL:</b><input type="text" name="feedURL" value="http://demos.javascriptref.com/newsfeed.xml" size="50" />
    
<input type="button" value="阅读" onclick="readRSS(this.form.feedURL.value);" />
    
<div>
    
    
</div>
    
</form>
    
<div id="feedOutput"><br /></div>
    
<h2>For other feeds try</h2>
    
<ul>
    
<li>http://rss.news.yahoo.com/rss/topstories</li>
    
</ul>
</body>
</html>
posted @ 2008-12-15 11:44 阿炳 阅读(271) 评论(2) 编辑
  2008年11月7日
摘要: Javascript中正则表达式的使用~很详细~阅读全文
posted @ 2008-11-07 22:06 阿炳 阅读(128) 评论(0) 编辑
  2008年9月28日
摘要: 如何通过双击文件打开自己编写的程序,比如自己编写的记事本,图片浏览器之类的。阅读全文
posted @ 2008-09-28 22:51 阿炳 阅读(1638) 评论(7) 编辑
  2008年9月15日

  以前试过在WinForm中自定义鼠标样式,结果显示出来的鼠标变成单色。

  后来百度了下,原来要用API来做。

     首先引入两个命名空间

 

using System.Runtime.InteropServices;
using System.Reflection;

 

导入API

 

        [DllImport("user32.dll")]
        
public static extern IntPtr LoadCursorFromFile(string fileName);

        [DllImport(
"user32.dll")]
        
public static extern IntPtr SetCursor(IntPtr cursorHandle);

        [DllImport(
"user32.dll")]
        
public static extern uint DestroyCursor(IntPtr cursorHandle);

 

 

接下来使用自己的鼠标样式

 

        private void Form1_Load(object sender, EventArgs e)
        {
            Cursor myCursor 
= new Cursor(Cursor.Current.Handle);
            IntPtr colorCursorHandle 
= LoadCursorFromFile("my.cur");//鼠标图标路径
              myCursor.GetType().InvokeMember("handle", BindingFlags.Public |
            BindingFlags.NonPublic 
| BindingFlags.Instance |
            BindingFlags.SetField, 
null, myCursor,
            
new object[] { colorCursorHandle });
            
this.Cursor = myCursor;
        }

 

      现在介绍另一种不用API方式的,鼠标样式只需要一张背景透明的图片就行了,png或gif格式的

     写个方法

 

        public void SetCursor(Bitmap cursor, Point hotPoint)
        {
            
int hotX = hotPoint.X;
            
int hotY = hotPoint.Y;
            Bitmap myNewCursor 
= new Bitmap(cursor.Width * 2 - hotX, cursor.Height * 2 - hotY);
            Graphics g 
= Graphics.FromImage(myNewCursor);
            g.Clear(Color.FromArgb(
0000));
            g.DrawImage(cursor, cursor.Width 
- hotX, cursor.Height - hotY, cursor.Width, 
            cursor.Height);

            
this.Cursor = new Cursor(myNewCursor.GetHicon());
           
            g.Dispose();
            myNewCursor.Dispose();
        }

 

在你想要改变鼠标样式的事件里头使用这个方法就行了

 

        private void Form1_Load(object sender, EventArgs e)
        {
            Bitmap a
=(Bitmap)Bitmap.FromFile("myCur.png");
            SetCursor(a, 
new Point(00));
        }
posted @ 2008-09-15 14:13 阿炳 阅读(1527) 评论(1) 编辑
  2008年7月30日
posted @ 2008-07-30 07:09 阿炳 阅读(183) 评论(1) 编辑