長(zhǎng)沙做網(wǎng)站官方站點(diǎn)精彩分享

国产成人精品日本亚洲999I久久资源在线I亚洲88avI久久久av免费观看I99re6热在线精品视频播放速度I91成人精品I夫妻avI五月天综合婷婷I五月色综合I久操视频在线播放Iwww.亚洲色图I国产一级免费观看I幸福花园动漫完整版双男主

讓網(wǎng)站實(shí)現(xiàn)簡(jiǎn)體和繁體轉(zhuǎn)換代碼

[ 2130 查看 / 0 回復(fù) ]

如果我們的網(wǎng)站有港澳臺(tái)的用戶,那么網(wǎng)站最好是能支持文字簡(jiǎn)繁互轉(zhuǎn),這樣做能方便不同用戶更好的閱讀網(wǎng)站內(nèi)容。要實(shí)現(xiàn)簡(jiǎn)繁互轉(zhuǎn)可以使用以下方法輕松實(shí)現(xiàn)。

  方法一:用js實(shí)現(xiàn)讓網(wǎng)站實(shí)現(xiàn)簡(jiǎn)體和繁體轉(zhuǎn)換代碼

  js簡(jiǎn)體,繁體轉(zhuǎn)換,IE7通過,Firefox不通過,可能原因是var obj=document.body.childNodes

  Firefox不能識(shí)別。希望以后能修正。js使用了jquery,請(qǐng)下載jquery,js代碼請(qǐng)下載/Files/genson/transfroms.rar
頁(yè)面代碼:
                            <span id="spanT">
                            |<A  href="#" class="topMenu" >繁體中文</A>
                            </span> 
                            <span id="spanS">
                            |<A  href="#" class="topMenu" >簡(jiǎn)體中文</A>     
                            </span>   

  方法二:.net代碼實(shí)現(xiàn)讓網(wǎng)站實(shí)現(xiàn)簡(jiǎn)體和繁體轉(zhuǎn)換代碼
//Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using EncodeMy;
namespace TestEnCode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
EncodeRobert edControl = new EncodeRobert();//創(chuàng)建一個(gè)簡(jiǎn)繁轉(zhuǎn)換對(duì)象
txtResult.Text= edControl.SCTCConvert(ConvertType.Simplified, ConvertType.Traditional,txtSource.Text);//進(jìn)行簡(jiǎn)繁轉(zhuǎn)換
}
}
}


注意:using EncodeMy;并非.net自帶的類庫(kù),在Encode.dll中。要引用一下的。
請(qǐng)到http://download.csdn.net/source/617532
http://download.csdn.net/user/farawayplace613下載(不需要資源分的)該實(shí)例的代碼。Encode.dll在Debug的文件夾內(nèi)。


//Form1.Designer.cs
namespace TestEnCode
{
partial class Form1
{
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
/// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要
/// 使用代碼編輯器修改此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.txtSource = new System.Windows.Forms.TextBox();
this.txtResult = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txtSource
//
this.txtSource.Location = new System.Drawing.Point(75, 26);
this.txtSource.Name = "txtSource";
this.txtSource.Size = new System.Drawing.Size(100, 22);
this.txtSource.TabIndex = 0;
//
// txtResult
//
this.txtResult.Location = new System.Drawing.Point(75, 126);
this.txtResult.Name = "txtResult";
this.txtResult.Size = new System.Drawing.Size(100, 22);
this.txtResult.TabIndex = 1;
//
// button1
//
this.button1.Location = new System.Drawing.Point(75, 78);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
this.button1.Text = "簡(jiǎn)繁轉(zhuǎn)換";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(23, 29);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 3;
this.label1.Text = "轉(zhuǎn)換源";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 136);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 4;
this.label2.Text = "轉(zhuǎn)換結(jié)果";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(320, 277);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.txtResult);
this.Controls.Add(this.txtSource);
this.Name = "Form1";
this.Text = "簡(jiǎn)繁體轉(zhuǎn)換測(cè)試";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtSource;
private System.Windows.Forms.TextBox txtResult;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
}



注意了,上面下載地下載的是VS2008創(chuàng)建的項(xiàng)目.
可能需要你把代碼拷貝到你自己的環(huán)境中。下載中重要的是Encode.dll。
TOP
主站蜘蛛池模板: 高潮毛片无遮挡 | 国产精品久久久久久免费 | 极品另类 | 男男车车的车车网站w98免费 | 深爱婷婷网 | 秋霞影院午夜伦 | 中文在线最新版天堂8 | 日韩精品久久久久久免费 | 性xxx法国hd极品 | 天天干影院 | 免费看黄20分钟 | 日韩精品视频网站 | 免费在线观看av的网站 | 亚洲精品777 | 国产婷婷色综合av蜜臀av | 亚洲国产毛片aaaaa无费看 | av全黄| 白白操在线视频 | 日韩欧美激情在线 | 国产亚洲精品美女久久久 | 人民的名义第二部 | 欧美日韩国产综合草草 | 爽爽影院在线 | 精品女同一区二区三区 | 午夜高潮视频 | 日韩精品在线视频免费观看 | 亚洲国产欧美在线观看 | 色婷婷av一区二区三区四区 | 欧美xxx在线 | 性色av无码久久一区二区三区 | 欧美色图激情小说 | 国产白嫩美女无套久久 | 日韩色高清 | 午夜激情小视频 | 日本不卡免费在线 | www.亚洲一区 | 亚洲精品视频在 | 国产伦精品一区二区 | 国产在线精品二区 | 欧美在线免费观看 | 欧美色图亚洲色 |