<Tr>
<Td class = "right">
<Span> * </span> Verification Code: </td>
<Td width = "165px">
<Input name = "checkcode" type = "text" maxlength = "4" class = "login_input" style = "width: 80px"
Id = "checkcode" runat = "server"/> </td>
<Td width = "146px">
Height = "40px" alt = "can't see clearly, change to" title = "can't see clearly, change to"/> </td>
<Td class = "left">
Onclick = "playvoice ('player');" align = "absmiddle"/>
</Td>
</Tr>
========================================================== ========================================================== ========================
<Script language = "javascript" type = "text/javascript" event = "onkeydown" for = "document">
If (event. keyCode = 81 & event. altKey)
{
Document. suggestForm. verifycode. focus ();
Playvoice ("player ");
}
</Script>
<Script type = "text/javascript" language = "javascript">
Function reloadcode ()
{
Var verify = document. getElementById ('safecode ');
Verify. setAttribute ('src', '../Common/getcode. aspx? '+ Math. random ());
}
Function playvoice (id)
{
Var voiceid = document. getElementById (id );
Voiceid. innerHTML = "<embed id = 'sound _ play' name = 'sound _ play' src = 'sound/sound_play.swf? "+ (New Date (). getTime () + "'flashvars = 'isplay = 1 & url = CodeVoice. aspx & code = "+ Math. random () + "'width = '0' height = '0' allowScriptAccess = 'always 'Type = 'application/x-shockwave-flash' pluginspage = 'HTTP: // www.macromedia.com/go/getflashplayer'/> </embed> ";
}
</Script>
Note:
1. Set Registe. aspx to the root directory. (The Voice function cannot be used if it is placed under a folder. The reason is not clear)
2. The files stored in the sound folder are: begin.mp3?end=and sound_play.swf.
CodeVoice. aspx in the root directory (delete all Page code and leave only header files)
The cs code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
// Read and verify the code to generate the MP3 package.
Response. ContentType = "audio/mpeg ";
Response. WriteFile ("Sound/begin.pdf ");
String checkCode = "";
If (Session ["CheckCode"]! = Null)
{
CheckCode = Session ["CheckCode"]. ToString ();
}
If (checkCode. Length> 0)
For (int I = 0; I <checkCode. Length; I ++)
{
Response. WriteFile ("Sound/" + checkCode [I] + ". mp3 ");
}
Response. WriteFile ("Sound/Endpoint ");
}
From: hongjiaoli Column