alzami Posted December 24, 2013 Share Posted December 24, 2013 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> Link to comment Share on other sites More sharing options...
Hadien Posted December 24, 2013 Share Posted December 24, 2013 (edited) you misspelled 'createLink'. you also need to make sure designMode is turned on. and while its on, events won't work in the current document, so you'll have to resort to using iframes. Or turn designMode on (inside the event call) to make the change and then turn it back off afterwards. Edited December 24, 2013 by Hadien Link to comment Share on other sites More sharing options...
davej Posted December 24, 2013 Share Posted December 24, 2013 https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozilla#Executing_Commands http://msdn.microsoft.com/en-us/library/ms533049(v=vs.85).aspx As usual, it isn't clear to me what you are trying to do. Link to comment Share on other sites More sharing options...
alzami Posted December 24, 2013 Author Share Posted December 24, 2013 (edited) thanks!spell correction works but it is not allowing me to click on the link and visit the desired page.rather "open in a new tab" using mouse's right button works.i want to make it a clickable link. iframe tag is used to creat browser window inside the main page(as far as i know).so why should i need an iframe tag here? // what i am trying to do is select a word or group of word and replae it with a link Edited December 24, 2013 by alzami Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now