web前端|js教程
输入框,选择内容
web前端-js教程
工作中遇到需要给输入框中选中的内容增加超链接
车贷网站完整源码下载,vscode帝国主题,ubuntu系统 只读,输出tomcat日志,sqlite生成一个表,爬虫采集数据存在的问题,php 去除bom,福建seo推广价格优惠,java源程序网站,wp 网页,dedecms 视频模板免费下载lzw
function addHref(des){
var selectedText="";
if(window.getSelection&&des != undefined){//兼容非IE浏览器,由于非IE浏览器需要给定操作的元素ID才可以获取输入元素中选中的内容,因此需要输入ID
体育竞猜 源码,vscode说明文档,ubuntu 教程分区,用cmd查看tomcat,网络爬虫分页,php 获取服务器地址,天门本地seo推广公司排名,婚嫁网站程序,phpcms 后台模板修改lzw
var textField=document.getElementById(des);
var selectionStart=textField.selectionStart;
var selectionEnd=textField.selectionEnd;
if(selectionStart != undefined && selectionEnd != undefined){
selectedText=textField.value.substring(selectionStart,selectionEnd);
}
if(selectedText==""){
alert("请选择需要添加链接的文字!");
return;
}
var hyperlinks=prompt("超链接地址:","");
if(hyperlinks!=null){
var replaceString="" + selectedText + "";
tmpStr=textField.value;
textField.value=tmpStr.substring(0,selectionStart)+replaceString+tmpStr.substring(selectionEnd,tmpStr.length);
}
}
else if((document.selection)&&(document.selection.type == "Text")){//IE中不需要ID
var range=document.selection.createRange();
var formerElement=range.parentElement();
if(formerElement.tagName!="TEXTAREA"){
alert("请在指定位置选择需要添加超链接的文字!");
return;
}
selectedText=range.text;
var hyperlinks=prompt("超链接地址:","");
if(hyperlinks!=null){
range.text="" + selectedText + "";
}
}
else{
alert("请选择需要添加链接的文字!");
return;
}
}
视频 采集站 源码,ubuntu 图形桌面开启,网页爬虫单词库,php 字模,昝辉 seolzw