比如,我在文本框里面输入一个网址。点击“获取标题”按钮,如何才能获取到标题并写入到下面的文本框里面。

解决方案 »

  1.   

    一个后端页面 gettitle.php (代码我复制的,没测试)
    function get_title($html)
    {
      $html=strtolower($html);
    $title = str_replace(" - ",",",cut($html,"<title>", "</title>" ));
    //if ($title == "") $title = "无标题";
    if ($title) $title=replace_word(textcut($title,80));
    if ($title) $title=preg_replace("/<(.*?)>/","",$title);
    return addslashes(trim($title));
    }
    你的前端页面 点击获取标题后 触发 ajax 到后端页面 取得返回的json 或字符串 赋值给你的相应input value
      

  2.   


     触发 ajax 到后端页面 取得返回的json 或字符串 赋值给你的相应input valueajax不会,求代码,兄弟,感谢了。。