長(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
主站蜘蛛池模板: 欧洲国产精品 | 日本高清黄色 | 水蜜桃影库 | 超碰在线网 | 少妇被多人c夜夜爽爽av | 免费在线小视频 | 国产一区精品在线观看 | 国产麻豆91视频 | 国产精品资源网 | 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美精品 在线观看 | 狐狸视频污 | 欧美在线免费视频 | 国产超碰人人做人人爽 | 国产系列第一页 | 亚洲少妇视频 | 亚洲 欧美 变态 另类 综合 | 国产高清露脸 | 一级中文字幕 | 6699嫩草久久久精品影院 | 黑人乱码一区二区三区av | 国产一区二区免费视频 | 欧美黄色免费网站 | 黄色免费毛片 | 国产干干 | 日本成人在线免费观看 | 2020亚洲男人天堂 | 国产成人在线一区二区 | 国产sm调教视频 | 精品无码一区二区三区的天堂 | 超碰国产91 | 伊人中文字幕在线 | 亚洲AV无码成人精品区在线观 | 国内精品二区 | 嫩草影院菊竹影院 | 三级在线视频观看 | 2020狠狠干| 亚洲一级在线观看 | 亚洲一区二区三区日韩 | 永久免费看mv网站入口亚洲 | 国产a v一区二区三区 |