惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - MFKSoft

IIS7运行WCF服务出现404错误的解决方法 [转]windows2008域服务器上创建实例报错,DIM-00019 租的吧 LOGO 全集 百度 父亲节 Logo 竟与 租的吧 “撞衫” 极速QQ作者向腾讯道歉 宣告永久停止更新 令人咋舌!瑞典设计师惊艳的PS修图作品 H1N1流感分布图 发短信赚2元话费咯 Ajax .NetFrameWork3.5 Sys未定义 解决方案 Doodle 4 Google “我的中国”谷歌国际少年绘画大赛 -- 作品赏 SharePoint 通过下拉框来筛选列表 - (续) - (更新) SharePoint 通过下拉框来筛选列表 不用寫程式也能客製化 - SharePoint 与SPD整合應用說明 Infragistics Resource String 对照表 -- UltraGrid Infragistics 部分控件汉化 VS2008简体中文正式版 + Team.Suite团队版 下载地址 告别黑色肺!禁烟公益广告海报 IBM开发新型内存 读写速度比闪存快10万倍 2008年Logo设计10大趋势
JavaScript控制文本被选中
MFKSoft · 2008-06-16 · via 博客园 - MFKSoft

在web开发中,有时候要用到js模拟鼠标的选中文本

 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 3<html>
 4<head>
 5<title>文本被选中</title>
 6<script type="text/javascript">
 7function selectItem1(){
 8  var mydiv = document.getElementById("myDiv");
 9  var range= document.body.createTextRange();   
10  range.moveToElementText(mydiv)   
11  range.moveEnd('character',-1);  
12  range.moveStart('character',-1);     
13  range.select();   
14}

15
16function selectItem2(){
17  var obj = document.getElementsByName("textRange")[0];   
18  var range = obj.createTextRange()   
19  range.moveStart("character",0);   
20  range.select();       
21}

22</script>
23</head>
24<body>
25<div id="myDiv" onclick="selectItem()">
26再过二十天左右就要面临高考了,1321321有许多考222生们目前正在紧张的复习当中。但是在北京出现 
27</div>
28<input type="button" value="选中上面的文本" onclick="selectItem1()" />
29</br>
30<input type="text" name="textRange" size="100" value="要检查您的网络连接,请单击工具菜单,然后单击 Internet 选项。"> 
31</br>
32<input type="button" value="选中上面的文本" onclick="selectItem2()" />
33</body>
34</html>