i want to creat link using selected text.codes aren't working.how can i fix this?

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#its{
    border:1px solid black;
}
</style>
</head>

<body>
<div id="its" contenteditable="true" >
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>
</div>
<input type="button" value="select and change" onClick="addLink();">
<script>
function addLink(){
var links=prompt("add link","http://");
document.execCommand('creatLink',false,links);
}
</script>
</body>
</html>

You should try

function addLink(){
document.execCommand('creatLink');
}

select some text of the document, click your addlink button and provide the location on the presented UI before hiting OK

mark solved threads general2012

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.