function FillUrls() {
var strdomin = $.trim($("#Text1").val());
var qsData = { 'wd': strdomin, 'p': '3', 'cb': 'ShowDiv', 't': '1324113456725' };
$.ajax({
async: false,
url: "http://suggestion.baidu.com/su",
type: "GET",
dataType: 'jsonp',
jsonp: 'jsoncallback',
data: qsData,
timeout: 5000,
success: function (json) {
},
error: function (xhr) {
alert(xhr);
}
});
}
function ShowDiv(strurls) {
var urls = strurls["s"];
}
<div style="display: none; position: absolute;" id="allSitesBoxHdl" class="classlist"
onmouseover="this.style.display='block'">
<ul id="allSitesBoxContent">
</ul>
</div>
#allSitesBoxHdl.classlist
{
position: absolute;
background-color: #F5FBFF;
width: 256px;
border: 1px solid #C9E4F4;
top: 28px;
left: 0;
text-align: left;
font-size: 14px;
line-height: 30px;
padding: 1px;
}
#allSitesBoxHdl.classlist li
{
display: inline;
}
#allSitesBoxHdl.classlist li.lis a
{
text-decoration: none;
height: 30px;
width: 210px;
float: left;
padding-left: 8px;
color: #666;
}
#allSitesBoxHdl.classlist li.lis a:hover
{
color: #016493;
background-color: #edf6fb;
}
#allSitesBoxHdl.classlist li.lis a:active
{
color: #016493;
background-color: #edf6fb;
}
#allSitesBoxHdl.classlist li.lis input
{
cursor: pointer;
color: #FF6600;
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
height: 22px;
margin: 4px;
line-height: 22px;
float: right;
background: #fff;
}
.wena
{
color: #666;
font-size: 12px;
height: 30px;
line-height: 30px;
width: 250px;
float: left;
}
//注册对象的事件
function Init() {
$("#allSitesBoxHdl")[0].style.display = "none";
$(":text").each(function () {
if ($(this)[0].getAttribute('url') == 'true') {//给所有的text加属性
$(this).bind("keyup", OnKeyup); //按键时
$(this).bind("mousedown", BoxShowUrls); //鼠标安下时
$(this).bind("mouseout", BoxHide); //鼠标离开时
$(this).bind("paste", OnPaste); //处理http;//
$(this)[0].setAttribute("autocomplete", "off");
}
});
}
;
var html = "";
if (urls) {
var urllist = urls;
var forlength = 0;
var stringcookie;
for (var i = urllist.length - 1; i >= 0; i--) {
var textval = urllist;
if ($.trim(textval) != "" && $.trim(textval) != "undefined") {
html += "<li class=\"lis\"><a href=\"javascript:InputSetValue('" + textval + "');\">" + textval + "</a></li><br/>";
}
}
} else {
html = "<li style='font-size: 12px;' > 没有记录</li>";
}
if ($.trim(html) == "") {
html = "<li style='font-size: 12px;' > 没有记录</li>";
}
getid("allSitesBoxContent").innerHTML = html;
}
//关闭输入法
function closeIME(e) {
var obj = e.target ? e.target : e.srcElement;
obj.style.imeMode = 'disabled';
}
function OnPaste(e) {
var obj = e.target ? e.target : e.srcElement;
setTimeout("MoveHttp('" + obj.id + "')", 100);
}
//修正URL
function MoveHttp(id) {
var val = getid(id).value;
val = val.replace("http://", "");
if (val[val.length - 1] == '/') {
val = val.substring(0, val.length - 1);
}
getid(id).value = val;
}
function OnKeyup(e) {
var obj = e.target ? e.target : e.srcElement;
setTimeout("addInput('" + obj.id + "')", 200);
}
//赋值
function addInput(id) {
var obj = getid(id);
//如果是一个没有True的input不执行
if (obj.getAttribute('url') == 'true') {
if (obj.value.indexOf('。') > 0) {
obj.value = obj.value.replace('。', '.');
}
var tags = document.getElementsByTagName('input');
for (var i = 0; i < tags.length; i++) {
if (tags.getAttribute('url') == 'true' && tags != obj) {
tags.value = obj.value;
}
}
}
FillUrls();
}
//注册对象的事件
function Init() {
$("#allSitesBoxHdl")[0].style.display = "none";
$(":text").each(function () {
if ($(this)[0].getAttribute('url') == 'true') {//给所有的url=true属性的Text加效果
$(this).bind("keyup", OnKeyup); //按键时
$(this).bind("mousedown", BoxShowUrls); //鼠标安下时
$(this).bind("mouseout", BoxHide); //鼠标离开时
$(this).bind("paste", OnPaste); //处理http;//
$(this)[0].setAttribute("autocomplete", "off");
}
});
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="Scripts/StyleSheet.css" rel="stylesheet" type="text/css" />
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/JScript2.js" type="text/javascript"></script>
</head>
<body>
<form style="text-align: center" id="form1" runat="server">
<br /> <br /> <br /> <br /> <br /> <br /> <br />
<input style="width:500px;" url="true" id="Text1" type="text" /><br/>
<input style="width:500px;" id="Text2" type="text" />
<div style="display: none; position: absolute;" id="allSitesBoxHdl" class="classlist"
onmouseover="this.style.display='block'">
<ul id="allSitesBoxContent">
</ul>
</div>
<script type="text/javascript"> Init();</script>
</form>
</body>
</html>
小浪子 发表于 2013-10-17 11:21
这样是等于调用百度的一个接口吗?
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |