您需要在
工作输入框中添加所选内容的超链接。
复制代码代码如下所示:
功能addhref(DES){
var = 教科书选文;
如果(window.getselectiondes!=未定义)与非IE
浏览器兼容,IE浏览器需要给出由于非
操作元素ID可以选择获得输入元素,所以您需要输入ID
VaR TextField = document.getelementbyid(DES);
无功selectionstart = textfield.selectionstart;
无功selectionend = textfield.selectionend;
如果(selectionstart!=定义的selectionend!=未定义的){
教科书选文= textfield.value.substring(selectionstart,selectionend);
}
如果(教科书选文= =){
警报()请选择您需要添加到链接中的
文本!;
返回;
}
VaR的超链接=
提示(超链接
地址:
如果(超链接)!= NULL){
无功replacestring = 教科书选文+ +;
textfield.value Javascript =;
tmpstr.substring TextField。值=(0,selectionstart)+ replacestring + tmpstr.substring(selectionend,Javascript。长度);
}
}
else if((
文件。选择)(document.selection.type = =文本))我不需要{ / /伊江
变量范围= document.selection.createrange();
无功formerelement = range.parentelement();
如果(formerelement.tagname!=文本){
警报()请选择您需要在指定
位置添加超链接的文本!;
返回;
}
SelectedText=range.text;
VaR的超链接=提示(超链接地址:
如果(超链接)!= NULL){
范围。文本= 教科书选文+ +;
}
}
别的{
警报()请选择您需要添加到链接中的文本!;
返回;
}
}