Current location: Hot Scripts Forums » General Web Coding » JavaScript » [FireFox] Cursor position in DesignMod iframe.


[FireFox] Cursor position in DesignMod iframe.

Reply
  #1 (permalink)  
Old 11-02-09, 01:49 AM
BurakUeda BurakUeda is offline
Newbie Coder
 
Join Date: Feb 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
[FireFox] Cursor position in DesignMod iframe.

Playing with ifames in designMode = "on"
Here is the code snippet:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript">
function start(){
	document.getElementById("testframe").contentWindow.document.designMode = "on";
}

function curpos(){
	var frame = document.getElementById("testframe").contentWindow;
	var sel = frame.getSelection();
	var range = sel.getRangeAt(0);
	var selStart = range.startOffset;
	alert(selStart);
}
</script>
</head>

<body onload="start()">

<iframe width="500" height="200" id="testframe" style="cursor:text"></iframe>
<hr />
<button onclick="curpos()">CurPos</button>

</body>
</html>
Code returns the correct position IF the text inside consists a single line.
Problem is multiline content. If you put something like:
Code:
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
1234567890
and put the cursor at a random position, and click the CurPos button, it returns sometimes the position of the cursor in that particular line, or sometimes some random number.

How can I get the cursor position at whole text?

Thanks.
__________________
http://humo.org
Just another general discussion forum
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
External link to iframe Techmom HTML/XHTML/XML 7 07-23-09 12:57 PM
Changing iframe src property not working in Safari AmberLR JavaScript 1 04-08-09 10:41 AM
drop-in iframe popover - once per browser session? Mylnda JavaScript 0 10-10-05 12:15 AM
js function / border & iframe cityonfire JavaScript 1 07-24-05 08:02 PM
Loading a new page in place a parent from an iframe Highly-Annoyed HTML/XHTML/XML 3 07-18-05 11:05 AM


All times are GMT -5. The time now is 01:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.