<tr id="vercode">
<td valign="top" class="f14">验证码:</td>
<td valign="top"><input type="hidden" name="spVcode" value="" />
<input type="text" onFocus="f_focus()" id="spVerifyKey" name="spVerifyKey" size="6"  maxlength="4" autocomplete="off" tabindex=4>  请点击后输入四位验证码,字母不区分大小写<br/>
<script type="text/javascript">
/*<![CDATA[*/function f_focus(){
getVcode();
}
function getVcode(){
var url="http://hi.baidu.com/sys/file/getvcode?echoback=getVcodeDone&t="+(new Date().getTime());
BdAjax.loadJS(url)
}function getVcodeDone(vcode){
document.form1.spVcode.value=vcode;
var imgsrc="http://hiup.baidu.com/cgi-bin/genimg?"+vcode;
G('verifypic').src=imgsrc;
G('yanzheng').style.display="block";
}
function newverifypic(){
getVcode();
return false;
}
/*]]>*/
</script>
<div id="yanzheng" style="display:none">
<img id='verifypic' width='120' height='40'><wbr /><a onFocus="this.blur();" href="#" onClick="return newverifypic();" title="看不清左边的字符" >看不清?</a>
</div>
</td>
</tr>
------------上面是BLOG 文章内容----------下面是要调用 的JS-----------------------
BdAjax.loadJS=(function()
{
var head ;
return function(jsUrl){
head = head || document.getElementsByTagName("head")[0];
var s=document.createElement("script");
s.type="text/javascript";
s.src=jsUrl;
head.appendChild(s);
} })();
大家帮忙看下
这是百度空间新改进的验证码功能 通过ajax 获取的JS  再将JS加入页面 想想大家怎么才能得到var imgsrc="http://hiup.baidu.com/cgi-bin/genimg?"+vcode;中的vcode 谢谢大家了 

解决方案 »

  1.   

    因为vcode是通过前台传了一个时间参数后由后台生成的,估计拿不到了。
      

  2.   

    我想他的时间参数只是让AJAX清空缓存 实际载入的是一个固定的JS 我想怎么才能得到appendChild(s)加入页面的内容 然后再分析 
      

  3.   

    验证图片应该不是appendChild加进来的,appendChild是在<head>标签里加入了一个<script标签,通过加入这个标签,从而执行了如下的URL,也就相当于动态调用了后台方法:
    http://hi.baidu.com/sys/file/getvcode?echoback=getVcodeDone&t="+(new Date().getTime()); 
    而验证图片应该已经写在页面里了:
    <img id='verifypic' width='120' height='40'>是不是在合适的时机查看这个图片的src就可以知道验证图片的路径?
      

  4.   

    我就是想得到http://hiup.baidu.com/cgi-bin/genimg?"+vcode; 中的vcode 
    当然查看图片是能看到vcode的值 但是在源代码里是看不到的呀  问题就出在这里了以前的在源码里能看见 现在改了 
      

  5.   

    document.form1.spVcode.value=vcode; 如果你用程序模拟点击输入框,回调函数里不是已经吧vcode父给一个form元素了吗?程序等待1S后直接拿这个值不行?
      

  6.   

    提取:
    "http://hi.baidu.com/sys/file/getvcode?echoback=getVcodeDone&t="+(new Date().getTime())返回:
    getVcodeDone("3035737061636531353038323530323135303030303030303030303030303031323430323139303738B10CAEBD66A524ABE45EA20D7DE6F267")括号中的字串即为 vcode 的值.
      

  7.   

    提取: 
    "http://hi.baidu.com/sys/file/getvcode?echoback=getVcodeDone&t="+(new Date().getTime()) 
    怎么提取呀???
      

  8.   

    这个不就是答案吗?(new Date().getTime())用来刷新页面文件的,每次请求的值唯一应该就可以了.
      

  9.   

     public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void button1_Click(object sender, EventArgs e)
            {
                webBrowser1.Document.GetElementById("spVerifyKey").InvokeMember("focus");
                timer1.Start();        }
            private void GetImg()
            {
                IHTMLDocument2 currentDoc = (IHTMLDocument2)webBrowser1.Document.DomDocument;
                foreach (IHTMLElement a in currentDoc.all)
                {
                    if (a.tagName== "IMG")
                    {
                        string src = a.getAttribute("src",0).ToString();
                        if (src.IndexOf("genimg") > -1)
                        {
                            textBox1.Text = src;
                        }
                    }
                }
                
            }
            private void Timer(object sender, EventArgs e)
            {
                timer1.Enabled = false;
                GetImg();
            }
        }