[jQuery] re-establish user selection in a div with designmode=true

2009-06-05 Thread dhoover

I have a web app where I have created a div to masquerade at a
textarea so I can add highlighting according to so rules. I rely on
setting designmode=true. After certain amounts of idle time my code
grabs the text from the div, which consists of p tags and span
tags and re-generates the html with new spans. The paragraphs and text
stay the same. So far so good. But when the div repaints the
insertion is set to the beginning of the div. I want it to visually
stay put, meaning I need to somehow record where it was before and
then restore it afterwards.

Problem is, I can't seem to get my head wrapped around how selections
(Ranges, etc.) work. I've been googling around for the last day or so
and have not yet seen the light.

Any ideas?


[jQuery] inline script html vs xhtml

2009-05-27 Thread dhoover

I am a bit perplexed at why a simple bit of code I have is firing in
HTML but not in the equivalent XHTML. Here is the HTML file (that
works as expected):

html
head
titleText Demo/title
meta http-equiv=Content-type content=text/html;charset=UTF-8
link rel=stylesheet type=text/css href=stylesheets/default.css
script type=text/javascript src=js/jquery-1.3.2.min.js/script
!-- script type=text/javascript src=js/jRewriter.js
charset=UTF-8/ --
script type=text/javascript
$(function() {
  alert(hi);
});
/script
/head
body
/body
/html

And here is the XHTML file (that does not work as expected):

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-
strict.dtd
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
titleText Demo/title
meta http-equiv=Content-type content=text/html;charset=UTF-8 /
link rel=stylesheet type=text/css href=stylesheets/default.css /

script type=text/javascript src=js/jquery-1.3.2.min.js /
script type=text/javascript
//![CDATA[
$(function() {
  alert(hi);
});
//]]
/script
/head
body
/body
/html

Is there something I am missing here?

Thanks.
Dean