Click here to Skip to main content
15,892,537 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Moving xml file fails Pin
Shog925-Oct-08 5:59
sitebuilderShog925-Oct-08 5:59 
GeneralRe: Moving xml file fails Pin
Ekjon27-Oct-08 5:18
Ekjon27-Oct-08 5:18 
GeneralRe: Moving xml file fails Pin
Shog927-Oct-08 5:26
sitebuilderShog927-Oct-08 5:26 
GeneralRe: Moving xml file fails [modified] Pin
Ekjon27-Oct-08 10:03
Ekjon27-Oct-08 10:03 
QuestionAdding a border to an image Pin
Brendan Vogt24-Oct-08 6:22
Brendan Vogt24-Oct-08 6:22 
AnswerRe: Adding a border to an image Pin
Mohammad Dayyan24-Oct-08 8:39
Mohammad Dayyan24-Oct-08 8:39 
AnswerRe: Adding a border to an image Pin
Drew Stainton24-Oct-08 8:42
Drew Stainton24-Oct-08 8:42 
QuestionJavaScript Selection/Range Problem [modified] Pin
Lea Hayes24-Oct-08 0:27
Lea Hayes24-Oct-08 0:27 
Hi,

I am working on a custom rich-text editor using contentEditable. When the return key is pressed I am preventing the default action, and inserting a line break tag to ensure that the browser doesn't create a paragraph element.

In IE I have this working great, but in Chrome, Safari, and FF the selection doesn't appear to update correctly. The break tag is inserted, but the input caret does not move. For test purposes I have replaced the break with a horizontal rule. Upon pressing enter, the caret should move after the HR element, but it doesn't.

<html>
<head>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
window.onload = function(event) {
document.observe('keydown', doc_keydown.bindAsEventListener(document));
}

function charCode(event) {
return typeof event.which !== 'undefined' ? event.which : event.keyCode;
}
function doc_keydown(event) {
var range;
var code = charCode(event);
switch (code) {
case 13: // return
if (document.selection) { // IE
range = document.selection.createRange();
range.pasteHTML("<hr />");
range.moveEnd("character", 1);
range.moveStart("character", 1);
range.collapse(false);
}
else { // FF, Google Chrome
range = window.getSelection().getRangeAt(0);
range.deleteContents();
var newNode = new Element("hr");
range.insertNode(newNode);
range.setStartAfter(newNode); // Doesn't work from here down.
range.setEndAfter(newNode);
range.collapse(false);
}
break;
default:
return true;
}
event.stop();
return false;
}</script>
</head>
<body>
<div contentEditable="true" style="border: solid 2px black; padding: 6px">
Some initial text - Edit Me!
</div>
</body>
</html>

Many thanks,
Lea Hayes

<div class="ForumMod">modified on Friday, October 24, 2008 6:39 AM</div>
AnswerRe: JavaScript Selection/Range Problem Pin
Aman Bhullar3-Nov-08 23:50
Aman Bhullar3-Nov-08 23:50 
QuestionRegular Expression Pin
ganeshMohan23-Oct-08 18:51
ganeshMohan23-Oct-08 18:51 
AnswerRe: Regular Expression Pin
Mohammad Dayyan24-Oct-08 2:47
Mohammad Dayyan24-Oct-08 2:47 
GeneralRe: Regular Expression Pin
Paul Conrad24-Oct-08 5:46
professionalPaul Conrad24-Oct-08 5:46 
QuestionDelegates in C# Pin
jainvidhya8423-Oct-08 3:34
jainvidhya8423-Oct-08 3:34 
AnswerRe: Delegates in C# Pin
Aman Bhullar3-Nov-08 23:55
Aman Bhullar3-Nov-08 23:55 
QuestionCannot retrieve the value from my session (cast type error) Pin
Aldeareao23-Oct-08 2:34
Aldeareao23-Oct-08 2:34 
AnswerRe: Cannot retrieve the value from my session (cast type error) Pin
Ashfield23-Oct-08 23:52
Ashfield23-Oct-08 23:52 
Questionjavascript problem in safari Pin
mynameissuraj22-Oct-08 22:44
mynameissuraj22-Oct-08 22:44 
QuestionDifference between session and static internal Pin
Kartik Rathi22-Oct-08 21:22
Kartik Rathi22-Oct-08 21:22 
AnswerRe: Difference between session and static internal Pin
Mohammad Dayyan26-Oct-08 0:00
Mohammad Dayyan26-Oct-08 0:00 
Question[Message Deleted] Pin
pzn3xq22-Oct-08 5:50
pzn3xq22-Oct-08 5:50 
AnswerCP IGNORE: Posted in THREE forums Pin
leckey22-Oct-08 7:31
leckey22-Oct-08 7:31 
AnswerRe: [Message Deleted] Pin
Mohammad Dayyan25-Oct-08 23:58
Mohammad Dayyan25-Oct-08 23:58 
Question[Message Deleted] Pin
pzn3xq22-Oct-08 5:46
pzn3xq22-Oct-08 5:46 
AnswerCP IGNORE: habitual cross poster Pin
leckey22-Oct-08 7:34
leckey22-Oct-08 7:34 
GeneralRe: CP IGNORE: habitual cross poster Pin
Paul Conrad22-Oct-08 7:51
professionalPaul Conrad22-Oct-08 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.