SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Location
    Odessa, Ukraine
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mozilla/Firefox problems with cursor position

    Hello, I wrote a piece of code to update code highlight in real time when a key is pressed... This works perfect with MSIE but I can't do the same with Mozilla/Firefox etc...
    The problem in mozilla is to keep cursor position (it put the cursor always on the start). Anybody can Help me ?
    Here's the code:

    PHP Code:
    //here I save the cursor position
    var rng document.getElementById('myEditor').document.selec tion.createRange();
    var 
    position = { left rng.offsetLefttop rng.offsetTop};
    // now I get the whole content of the body
    content=document.getElementById('myEditor').conten tWindow.document.body.innerHTML;
    content=uncolorTags(content); // uncolor the tags (remove spans) (some string.replaces)
    content=colorTags(content); // here I recolor the tags (re create spans) (some string.replaces)
    // now I restore the updated content
    document.getElementById('myEditor').contentWindowdocument.body.innerHTML=content;
    // here I restore cursor position
    rng.moveToPoint(position.leftposition.top);
    rng.select(); 

  2. #2
    SitePoint Member
    Join Date
    Jul 2006
    Location
    Odessa, Ukraine
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    up :/

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Location
    Odessa, Ukraine
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    another question: how I can move my cursor to the end of text in Firefox? I can take all content:
    PHP Code:
    range document.createRange();
        var 
    content document.getElementById(pointer).contentWindow.document.getElementById('main_body');
        
    range.selectNodeContents(content);
        var 
    range_cont range.toString(); 
    And after it how I can move my cursor?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •