?
Solved

cursor position

Posted on 2006-04-27
3
Medium Priority
?
385 Views
Last Modified: 2008-01-16
I have an iframe like:

    <iframe id = "ddd"></iframe>

the user can type some text in it when design mode is on.

Is there a function I can use to automatically move the cursor to the end of the iframe?

Thanks
0
Comment
Question by:minnirok
3 Comments
 
LVL 14

Expert Comment

by:sam2912
ID: 16558528
When you mean cursor, do you mean mouse cursor or text cursor? You definitely can't move the mouse cursor.
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 16558913
You might want a textarea or textbox for that.
0
 
LVL 15

Accepted Solution

by:
dbritt earned 2000 total points
ID: 16559044
Absolutely.

But as was suggested, you're asking about the "caret", not the "cursor" ;)

Enjoy! ^^

======================================
test.html
======================================

<html>
<head>
      <title>Test Page</title>

      <script language="JavaScript" type="text/javascript">
      
      function runTest()
      {
            var bdy = ddd.document.body;

            if (bdy.createTextRange) {
                  var range = bdy.createTextRange();
                  range.collapse(true);
                  range.moveEnd('character', bdy.innerHTML.length);
                  range.moveStart('character', bdy.innerHTML.length);
                  range.select();
            }
      }
      
      </script>
</head>

<body>

      <input type="button" value="Run Test" onclick="javascript:runTest();">

      <br><br>

      <iframe id="ddd" src="iframe.html"></iframe>

</body>
</html>


======================================
iframe.html
======================================

<html>
<head>
      <title>The IFrame</title>
</head>

<body contenteditable="true">
Howdy

<br><br>

<span id="test"></span>

<br>

:)
</body>
</html>
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question