<HTML>
<BODY>
<H1 unselectable="on">Creating a Link and Retrieving the URL</H1>
<script>
function AddLink(){//Identify selected textvar
sText = document.selection.createRange();
if (!sText==""){
//Create link
document.execCommand("CreateLink");
var len = sText.parentElement().childNodes.length;
for(var i=0;i<len;i++){
if (sText.parentElement().childNodes[i].tagName == "A"){
sText.parentElement().childNodes[i].target = "_blank";
}
}
}else{
alert("Please select some blue text!");
}
}
</script>
<P unselectable="on">Select any portion of the following blue text, such as "My favorite Web site". Click the button to turn the selected text into a link. The text will be changed to the URL that you specify.</P>
<P style="color=#3366CC">My favorite Web site is worth clicking on. Don't forget to check out my favorite music group!</P>
<BUTTON onclick="AddLink()" unselectable="on">Click to add link</BUTTON>
</BODY>
</HTML>
分享到:
相关推荐
document.execCommand()的用法
execCommand指令集详解,javascript进阶是常用的参考资料
javascript 的execCommand和操作剪贴板的收集
html中的内容直接下载到excel中的demo,替换 document.execCommand(‘saveAs’)方法
NULL 博文链接:https://vb2005xu.iteye.com/blog/319918
case 7: E.document.execCommand('CreateLink',true,'true') break; case 8: if(_Text!='') { var _CText=RemoveHTML(_Text); Ebody.innerHTML=Ebody.innerHTML.replace(_Text,_CText); }else{ if...
2D-Position 允许通过拖曳移动绝对定位的对象。 AbsolutePosition 设定元素的 position 属性为“absolute”(绝对)。... CreateLink 在当前选中区上插入超级链接,或显示一个对话框允许用户指定要为当前选中区插入的超级
2D-Position 允许通过拖曳移动绝对定位的对象。 AbsolutePosition 设定元素的 position 属性为“absolute”(绝对)。... CreateLink 在当前选中区上插入超级链接,或显示一个对话框允许用户指定要为当
首先要说明的是在firefox下支持不好。2D-Position 允许通过拖曳移动绝对定位的对象。 AbsolutePosition 设定元素的 position 属性为“absolute”(绝对)。... CreateLink 在当前选中区上插入超级链接,或显示一个
Js之execCommand解析.pdf
主要给大家介绍在JavaScript中如何解决用execCommand("SaveAS")保存页面兼容性问题,设计到execCommand兼容性问题,感兴趣的朋友可以参考下本
执行命令 一个非常简单的包装器,用于在 NodeJS ... var execCommand = require ( "execCommand.js" ) ; var command = execCommand ( "cat /sys/class/thermal/thermal_zone0/temp" ) ; console . log ( command ) ;
代码如下: D-Position 允许通过拖曳移动绝对定位的对象。 AbsolutePosition 设定元素的 position 属性为“absolute”(绝对)。... CreateLink 在当前选中区上插入超级链接,或显示一个对话框允许用户指定要为当前选中区
IE6下设置背景图片是不会被真正cache住的,就算服务器做了cache,如果想cache住只能
:no_entry: 已淘汰 :no_entry: create-react-app现在本地支持打字稿-请到现有项目。 对于要升级的现有react-scripts-ts用户,请。 我已选择存档此存储库,如果您需要与我联系,请访问Twitter @willmonk。react-...
contentEditables 中 document.execCommand 的一个稍微甜一点的 api。 目标: 公开一个更容易发现的 api 以在 contentEditables 中使用。 由 DIY WYSIWYG 工具栏控制的基本功能 无依赖 ~200 行(5k-ish 未压缩) ...