在IE中可以,但不支持 FF。
1.1.点击复制INPUT内容 鼠标在QQ号上点一下: 可以通过定义input的style来定义背景和边框属性,很方便的说。
<CoolCode>
<script type="text/javascript">
function copyText(obj)
{
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);}
</script>
以下是代码片段:
<span id="tbid"><a href="<a href="http://day8.com.cn/web/ro" target="_blank">http://day8.com.cn/web/ro&... target="_blank"><a href="http://day8.com.cn/web/ro" target="_blank">http://day8.com.cn/web/ro&...
[<a href="#" onclick="copyText(document.all.tbid)">点击复制</a>]
<span id="tbid2"><a href="<a href="http://day8.com.cn/web/ro" target="_blank">http://day8.com.cn/web/ro&... target="_blank"><a href="http://day8.com.cn/web/ro" target="_blank">http://day8.com.cn/web/ro&...
[<a href="#" onclick="copyText(document.all.tbid2)">点击复制</a>]
</CoolCode>
<script language="JavaScript" type="text/javascript">
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}
// Example:
// alert( readCookie("myCookie") );
function readCookie(name)
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}
</script>
引用以下asp代码改成的,js代码方便,但有些工具可以绕过JS,用js防止“低手”,节约一部分服务器资源,而用asp防止绕过js判断的“高手”。
结合CMS的封IP,把本地的127.0.0.1也封掉,效果会好些:
<%
Dim AppealNum,AppealCount
AppealNum=10 '同一IP60秒内请求限制10次
AppealCount=Request.Cookies("AppealCount")
If AppealCount="" Then
response.Cookies("AppealCount")=1
AppealCount=1
response.cookies("AppealCount").expires=dateadd("s",60,now())
Else
response.Cookies("AppealCount")=AppealCount+1
response.cookies("AppealCount").expires=dateadd("s",60,now())
End If
if int(AppealCount)>int(AppealNum) then
response.write "抓取很累,歇一会儿吧!"
response.end
End If
%>
[html]
12345678901234567890123456789012345678901234567890123456789012345678901234567890
[/html]