createTextRange() problem with firefox

Ok I have this code that works with IE but doesn’t work with firefox and I believe it is due to the fact that createTextRange() doesn’t work with firefox. Is there any way to make this code work? Here is the code;

if(document.REPLIER)
window.onbeforeunload=function()
{
r=document.REPLIER.Post.createTextRange()
r.select()
r.execCommand('copy')
}

The error given in the console is

Error: document.REPLIER.Post.createTextRange is not a function
Source File: http://acertaincite.com/index.php?act=Post&CODE=02&f=1&t=5
Line: 928

Does anyone know the solution?

http://www.mozilla.org/editor/midas-spec.html
http://www.dotvoid.com/view.php?id=11

so…

This means that the Range object is useless for implementations dealing with attributes, such as the text within an input element or textarea element.
I’m trying to get text out of an textarea element. It probalby won’t work is what you are telling me. Is there any way you can see to get around this? probably not right?

I guess I should read references before I link to them.

If you had explained what you were trying to do in the beginning…
JavaScript: Copy to Clipboard

ok, so I’ve pretty much figured out that at this current time this is pretty much not possible in firefox. To make it work each person who came to your page would have to sign the script in the about:config. Thanks for all the help

You’re welcome :slight_smile:

No, they would not have to go into about:config.

They would be presented with a warning box asking if they wanted to allow the script to run or not.

This is just one of many features that makes Firefox more secure than IE.

wait… really? hmmm, well that still works for what i want. Now I will have to make this thing work for what I want… this could be hard… I shall try. Ok so what I will be doing is using that code in here

if(document.REPLIER)
window.onbeforeunload=function()
{...modified version of that code...)
}

and when your hit the back button or go to a different website or exit the browser the text is copied to the clipboard without a popup message telling you what you copied, but if you use firefox you will get one popup message warning. I hope I have this right and can make this work.

Why?

Using the clipboard to store form data without the user’s knowledge is an extremely bad idea. Why don’t you use a cookie? Cookies will work in many, many more browsers.

I want to use this code in a community forum, it is in the post area, sometimes people are writing their post and they hit the back button or exit the browser by accident or an error occurs and when that happens the code above in ie copies their text to the clipboard so they don’t lose it. Do I find this useful? no, this is a stupid idea i agree, it is other people who want it and apparently use it and want it to work in firefox. I have to study for an exam so I haven’t tried the code yet.

You should suggest that they get the Autoform extension for Firefox instead.

…i can’t figure out what it does…

It can store the data from forms and then reload them.

Look at the screenshots.

looks pretty good, but I don’t think it is pratical for this situation. If it was for just one forum community you could tell your firefox users to get this, but it’s a little harder when it is 6000 different forum communities. If I can’t get this code to work well, then I will just attach a comment for the admin of the different communities about that extension.