Execommand to create hyperlink
2005-08-09 09:43
399 查看
<HTML>
<BODY>
<H1 unselectable="on">Creating a Link and Retrieving the URL</H1>
<script>
function AddLink()
{//Identify selected text
var sText = document.selection.createRange();
if (!sText==""){
//Create link
document.execCommand("CreateLink");
//Replace text with URL
if (sText.parentElement().tagName == "A"){
//sText.parentElement().innerText=sText.parentElement().href;
document.execCommand("ForeColor","false","#FF0033");
}
}
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>
<BODY>
<H1 unselectable="on">Creating a Link and Retrieving the URL</H1>
<script>
function AddLink()
{//Identify selected text
var sText = document.selection.createRange();
if (!sText==""){
//Create link
document.execCommand("CreateLink");
//Replace text with URL
if (sText.parentElement().tagName == "A"){
//sText.parentElement().innerText=sText.parentElement().href;
document.execCommand("ForeColor","false","#FF0033");
}
}
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>
相关文章推荐
- How to create a hyperlink in SQL Server Reporting Services
- How to: Create a hyperlink to view test results from an email(test manager)
- 点击eclipse日志中的链接提示:Unable to parse type name from hyperlink
- TcpSocketLink OutOfMemory,java.lang.OutOfMemoryError: unable to create new native thread 问题解决过程小记
- 164.Examine the command that is used to create a table: SQL> CREATE TABLE orders( oid NUMBER(6) PRI
- C# Adding Hyperlink to Windows Form z
- sublime 2/3 for mac link to command
- 如何创建软链接 how to create a symbolic link in clearcase
- OSX “open” command to create new files with an app
- How to create details page link in Windchill
- Fatal error in launcher: Unable to create process using '"D:\pytghon2.7\python.exe" "D:\python2.7\S
- Using Visual Studio 2005, MakeCab.exe and MSBuild to Create Window SharePoint Services v3 Solution Files (*.WSP's)
- cp: cannot create symbolic link to fat format of usb: Operation not permitted
- uboot配置时ln: failed to create symbolic link ‘asm’
- How to extract msu/msp/msi/exe files from the command line
- Create a link from SQL SERVER to Nortel CCM7 (InterSystems Cache DB)
- Using WPF DataGridHyperLinkColumn Items to open Windows Explorer and open files
- Powreshell.exe to get full commandline of a specified process
- How can I get a FlowDocument Hyperlink to launch browser and go to URL in a WPF app?
- FND:How to create a link in IE favorite to directly login into apps