Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    JavaScript


Advertisements:










Document.selection.createRange();


Is there a NS7, Opera7 or Mozilla equivalent for:

document.selection.createRange();


View 1 Replies (Posted: July 20th, 2005)

Sponsored Links:

Related Forum Messages For JavaScript category:
C# - Document.selection.createRange() Not Working In Chrome And Safari?
I am using a textbox with textmode as multiline option its working fine in IE,Mozilla problem occurs in Chrome and safari. Sample code folows

<asp:TextBox ID="txtRootDescription" onpaste="DoPaste(this);" Width="600px" Rows="10" Columns="72" MaxLength="500" TextMode="MultiLine" runat="server"></asp:TextBox>
function DoPaste(control) {
maxLength = control.attributes["maxlength"].value;
if (maxLength) {
var oTR = control.document.selection.createRange();
}}

in chrome it gives me an error as "Cannot read property 'selection' of undefined"

Posted: Aug 11 11 at 6:04

View 3 Replies!   View Related
Limits To The Amount Of Text One Can 'grab' With Window.getSelection Or Document.selection.createRange()?
I can't seem to find this info anywhere?Do window.getSelection() or document.selection.createRange() hold a set # of characters or can they hold an infinite/huge #?I am working on a bookmarklet and want to know if I need to restrict the amount of text one copies.

Posted: Jun 14 11 at 20:40

View 1 Replies!   View Related
IE's Document.selection.createRange Doesn't Include Leading Or Trailing Blank Lines?
I'm trying to extract the exact selection and cursor location from a textarea. As usual, what's easy in most browsers is not in IE.

I'm using this:

var sel=document.selection.createRange();
var temp=sel.duplicate();
temp.moveToElementText(textarea);
temp.setEndPoint("EndToEnd", sel);
selectionEnd = temp.text.length;
selectionStart = selectionEnd - sel.text.length;

Which works 99% of the time. The problem is that TextRange.text doesn't return leading or trailing new line characters. So when the cursor is a couple of blank lines after a paragraph it yields a position at the end of the preceeding paragraph - rather than the actual cursor position.

The only fix I can think of is to temporarily insert a character before and after the selection, grab the actual selection and then remove those temp characters again. It's a hack but in a quick experiment looks like it will work.

Posted: Sep 1 10 at 23:26

View 3 Replies!   View Related
CreateRange() In Browsers != IE
I have a nice Javascript code which allows users to HTML format code in a textarea, similar to the code of Post New Thread page. It works great in Internet Explorer but it does nothing in other browsers.

It seems the problem resides in this two lines:

Code:
a=document.selection.createRange();
seleccio = a.text;
How can I arrange this lines in order to make them cross-browser? I really need this code to work, at least, in current versions of Netscape, Mozilla and Opera.

Posted: Mar 19, 2003, 01:59

View 2 Replies!   View Related
Get HTML Markup For CreateRange() In Firefox?
I am currently using code similar to this code...

As you can see, I am accessing a node from an iframe (no fun already). I am definitely in new territory here, so am sure there are more issues to arise, but right now, I am trying to get Firefox to give me the same result as IE.

In IE, I can access the HTML code of the selection by using the (apparently IE-only) htmlText property of the object returned by createRange(). What I am looking for is the Firefox equivalent to that (or a function that I can use to give me the same result).

Anyone know how to do this?

Posted: Apr 13 10 at 16:58

View 1 Replies!   View Related
Document.selection
function spawn(ev){
var oSelect = ''
var oFlag = false;
if (ns4 || ns6)
oSelect = document.getSelection();
else if (ie4 || ie5){
if (!ev)
ev = window.event;
oFlag = true;
oSelect = document.selection;
}
alert(oSelect.type);
}
if (oSelect == '')
return;
else{
//stuff
}

In Netscape 4.8 if text is not selected nothing happens which is what I want. Please
disregard the fact that oSelect.type is not Netscape compatible you are really
seeing only a partial of what I am doing.

The issue here comes from this page: Code:

Posted: July 23rd, 2005

View 5 Replies!   View Related
Document.selection.empty()
Is there a way to achieve in Firefox (and other browsers) what I achieve in
IE6 with the document.selection.empty()? I want to be able to empty the
selection every time the user clicks a certain area, thus making it
impossible to select any text in that area. Is there a way to clear the
text selection in Firefox?

Posted: August 5th, 2005

View 3 Replies!   View Related
Way To Modify Document Selection In Script?
I wanna modify the document selection (user currently selected by mouse or keyboard), how to do it in a cross browser way?

Posted: Jan 15 10 at 22:59

View 2 Replies!   View Related
Document.selection Not Working In Mozilla
Following code i modified to make it work in the firefox browser.

but its not working in firefox

if (document.selection)
{
var objRange = document.selection.createRange();
var sOldRange = objRange.text;

[Code]....

Posted: Feb 18, 2010

View 5 Replies!   View Related
W3C Equiv Of Document.selection.clear()
According to Google I'm the first person ever to have had this problem. I'm looking for the Gecko equivalent of document.selection.clear() or (better) document.selection.empty().

I'll try to lay out what I'm trying to do. I register an mouseup handler on the document to fire a function to find what text is selected. Code:

Posted: May 9, 2005, 01:49

View 7 Replies!   View Related
Chrome Supports Document.selection?
im new to javascript, trying to perform: document.selection.createRange();

but document.selection returns always "undefined". im using latest version of chrome.

Posted: Aug 9 11 at 22:23

View 3 Replies!   View Related
Get The Current Selection 'index' Within A Document?
My code here returns a JavaScript selection object from within an iFrame (the iFrame page is within the same domain, so no xss issue).What I need to know is the index of the selection within the raw html code (not the dom).UPDATE:E.g.If you have an html doc:

<html><body>ABC</body></html>

Posted: Oct 27 10 at 7:39

View 4 Replies!   View Related
Pinpoint A Word Or A Selection In The Entire Document?
I am trying to highlight a part of the text on my website. This highlighted text will be saved for the specific user in a database and when the document is opened again it will show the previously highlighted text. I assumed I would be using javascript to highlight the text but I cannot seem to find a way to pinpoint where the word is that I am highlighting.

[Code]...

I am using that to get the selection but I cannot figure out where the selection is in the text. The biggest annoyance is when I have duplicates within the line or text so if I were to use search then I would find the first instance and not the one I was looking for. So the question is : How do you pinpoint a word or a selection in the entire document?

Posted: Mar 7 11 at 2:35

View 3 Replies!   View Related
Find Selection In HTML Document That Contains Iframe Or Just Frames?
Is there a way to find the selected text in an HTML document if the text may be within one of its frames (or iframes)?If the document has no frames it's simple:

var text;
if (document.getSelection) {
// Firefox and friends

[code]....

Posted: Apr 30 09 at 19:57

View 1 Replies!   View Related
JQuery :: Internet Explorer - Document Ready Selection Opacity 0 IE Delay?
on doc ready i've got my selection that set elements opacity:0 and than animate them to 1.It's nice on Safari and FF but in IE on window ready i see elements appears a moment before javascript was applied to them. I've to set visibility none for all of them via css ?

[Code]...

Posted: Dec 3 10 at 10:20

View 2 Replies!   View Related
Using QUnit To Test Utility Functions That Use Document.write(): Make Document Object Be Some Other Document?
I have a pair of utility functions that use document.write() to alter the DOM, injecting tags that load JavaScript and CSSIs it possible to use QUnit to test that the injection is happening correctly without having it impact the actual DOM of the test results page?I can:Overwrite document.write(), perhaps in setup and resetting it in teardown, to be a function I define. But them I'm not testing that the calls to document.write() do what they're supposed to do.

Use something like js-test-driver to have the JavaScript run from a command line (although I really want to have the test results page available).Create a separate test results page just for these utility tests so that those results don't affect the other tests in any way, shape, or form (although I really want a single unified page).Pass the utility functions empty JS and CSS files to load so they don't actually impact the results page.So I have options. But what I really want is to make document be some document other than the actual current document. I'm not sure this is possible. (In fact, I'm not even sure it makes any sense.) Is this possible? It seems like something I might be able to do with an iframe or something like that.If it helps at all, here's an example of the type of function I want to unit test:

function(jsFile){
document.write('<script type="text/javascript" src="'+jsFile+'"></script>');
}

[code]....

Posted: Oct 17 11 at 4:00

View 1 Replies!   View Related
When Call Document.createElement(...) On A Particular Document - Does That Newly Created Element Only Apply To That Original Document
When you call document.createElement(...) on a particular document, does that newly created element only apply to that original document, or can it be inserted into other accessible windows / document trees?

Posted: Jun 25 11 at 2:51

View 1 Replies!   View Related
Jquery :: Tab Selection - Previous Article Css - Button Selection And Html Tags
I have a problem related to my previous article css, button selection and html tags Not very good with javascript if any one could offer some insight as to where im going.

[Code]...

Posted: Mar 6 11 at 17:54

View 2 Replies!   View Related
Jquery :: Absolute Selection To Relative Selection Using $(this)
Say there is a selector $("#someID p") and that $(this) = $("#someID"). What selector would always be equal (if it was more complicated, like the example below) starting with $(this). Example: I have the following selector: $(tableMap.id + " tr:eq(" + i + ") td:eq(" + j + ")") On that line, I have $(this) being equal to $(tableMap.id). How would I remove tableMap.id from the first line and still keep the rest of the selector?

Posted: Sep 2 10 at 7:12

View 2 Replies!   View Related
JQuery :: Radio Button Selection / De-selection
I'm currently using jQuery on some radio buttons.When the user clicks a radio, a function is called that removes the checked attribute from all other radios and disables input fields associated with other radios. For example, when one radio is clicked,[code]

Posted: Mar 17 11 at 18:13

View 1 Replies!   View Related
Disable One Selection Box Based On A Selection In Another?
I have two selection boxes in the same form. I would like to have one disabled based on some of the options that can be selected in the other selection box. I'm looking for a solution in JavaScript if possible.

Posted: Aug 11 10 at 22:10

View 2 Replies!   View Related
Collapse Selection To Start Of Selection - Not Div
How can I collapse selected text in a contentEditable div to the start of the selection, not the entire div?

Posted: Dec 14 at 23:48

View 1 Replies!   View Related
Detect ,on Load Of The Html Document, Whether The Body Of The Iframe Document Is Ready To Be Displayed?
Suppose a HTML document has a iframe.Using javascript,I want to detect ,on load of the html document, whether the body of the iframe document is ready to be displayed.I want to be able to overwrite the the body contents (before it actullay loads) of the iframe.say if ,HTML doc is

<html>
<head>
</head>[code].....

Posted: Sep 7 09 at 5:52

View 1 Replies!   View Related
JQuery :: $(document).ready() - Are Multiple Bindings To The Document Load Event Allowed?
Does jquery support multiples of

$(document).ready(function() {});

ie. can i make a few of these on the same page and they will all be executed? or does the newest one overwrite the last?

Posted: Jul 8 10 at 13:42

View 1 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved