How Can I Restrict ExecCommand('undo') To A <div>?
Jul 23, 2005
I am using IE 6.0. On a page, I have placed a contenteditable div
which I want to use as a Rich Text Area. I am using the execCommand method of
the document to control bold, italics, underlining, and undo for this div.
I have placed an input element on the page to. All but the undo, are
restricted to working only on the div. How can I restrict the undo to
working on only the div?
Below is the complete page so you can see what I am talking about.
Just paste it into an htm file and traverse to it via your browser.
Type something in the div and the input and then try the buttons. Code:
im working with execCommand and trying to make a function to insert a youtube video into a content editable div with execcommand inserthtml. Now this works with every other browser except, OMG IE. now i am trying to use pasteHTML(), found that some people have gotten it to work, for its part but for some reason it is not working
I'm working on an undo-redo function. Couldnt really find anything useful in the internet. So I have a try. Guess it could be quite useful for a lot of people out there.
Wonder if the concept is any good?
Please critizise hard! Try it out if you dare! Any feedback is welcome! All suggestions are appreciated!
Yours
Axinya
--> <html> <head> <style type="text/css"> <!-- #wisiwig { overflow: auto; position: relative; height: 300px; width: 600px; margin-top: 5px; padding: 5px; border: thin groove #999999; } --> </style> <script language="JavaScript"> <!-- var b_ackup = new Array(); //Store data in Array var undo_pos= 0;//Position of undo var flag = false;// shall we start new undo thread and delete obsolete items? var w_isiwig;//editor interface
} else{//write to backup array b_ackup[b_ackup.length] = w_isiwig.innerHTML; undo_pos = b_ackup.length - 1; flag = false; w_isiwig.focus(); } }
function undo(){
if (b_ackup.length){//
if(undo_pos==0){w_isiwig.focus();return;}// beginning of backup items
if(flag == false){BACKUP();}// save last state of document
w_isiwig.innerHTML=b_ackup[undo_pos -1];
undo_pos=undo_pos - 1;
flag = undo_pos +1;
look();
w_isiwig.focus(); } }
function redo(){ if(undo_pos == b_ackup.length -1){w_isiwig.focus();return;} //end of backup array
w_isiwig.innerHTML=b_ackup[undo_pos +1];
undo_pos=undo_pos + 1;
flag = undo_pos +1; look(); w_isiwig.focus();
}
function look(){// monitor our Array data var e='flag:'+flag+' undo_pos:'+undo_pos+' ' e+='b_ackup.length:'+b_ackup.length+' ' for (i=0; i<b_ackup.length; i++){
I find most rich internet text editors, developers put in the product many many features but fail to make a decent undo redo mechanism, I pressed crtl+z they deleted my whole paragraph. Unlike googledocs's one, it knows exactly what to undo.
If anyone can let me know what the logic of google docs/Ms word machanism is, maybe I can give it shot building one.
Can I use execCommand to save just the contents of a textfield as a PHP file on a users computer? I've been searching for an hour and can't figure out how to do it.
Does anyone know of a way to wrap custom tags around selected text using execCommand or otherwise?
I am developing a rich text editor for use in a web site and while there are a few decent ones already floating around I need to implement a few extra bits of functionality. Specifically tool tips. Idealy I'd like to wrap custom tags around selected text using execCommand. Ie "Selected Text" becomes:
I'm (experimenting) writing my own RTE in JavaScript, I'm doing pretty good until it comes to the commands, the execCommand method. Here's what I have so far:
I am attempting to write a wysiwyg text editor to use in back-end site administration forms. It's working pretty well, aside from one error: when I hilight a large block of text and change the font, the change only applies to portions of the text selected (which appears to be random portions). Here is the javascript I'm using:
Code:function applyFont() { document.all.rtEditor.focus(); document.execCommand(fontname, false, document.all.fontNameSelector.value);}Where am I going wrong?
I'm using an HTML page with one section having editable content. Nothing overly complicated. All other execCommands are working fine, but I cannot get Paste to work. The function is called from this button:
And, here's the Javascript function:
When I use the Copy or Cut buttons the selected text is loaded into the clipboard. If I press Ctrl+V to paste, it works fine. But clicking the Paste button either has no visible effect (if no text is selected) or just deletes any selected text. I've used the Paste command before from VB without any problem, but it's been awhile since I've used JS.
I am having a problem with my wysiwyg editor for my site, users dont like the fact that you have to select text before you create a link and I was wondering if it was possible to prompt the user to add title text before you use the execCommand('createlink') and use that has the select text that they made from the prompt. Instead of the old way where you must select text first to use execCommand('createlink') to create a link. kind of like Sitepoint's insert link function but instead prompts the user for the title and doesn't insert bbcode but a anchor tag?
have made a homepage with nvu and works good but want to restrict access to all pages except the main page. i want everyone that tries to access a subpage directly to be redirected to the mainpage.
is there any simple way to achieve that ? must be in html or javascript.
How do i restrict files types that can be accessed when using the input element type file...like the one used when uploading..how do i restrict it to certain files with given file extensions?
I've a textbox field, where user enters his name. I want to restrict him from entering double and singls inverted commas.What kind of function should i write.
I need to restrict an area on the image but also get the coordinates from the image. I am using a form element "input type=image" so I can get the X Y coordinates from an image. I don't want the user clicking on a whole image, in this case a map of a country. I don't want the users clicking off the country's borders in to another country and I want to be able to get the coordinates from inside the country. I have tried to mix the element from the form with the area shape so when someone will click on the image it will first verify if it's over the hotspot and if it's over the poly coords then it will allow the user to click, the form will submit and the coordinates will be stored into the database.
I just don't know how I could integrate javascript into this. This is my code, not really something functional, the coordinates will pass on to the next page as a variable but limiting the area where the users may click is something that I have not figured out. I can create an area shape but without getting the coordinates from the image. Anything will do, even without <input type=image , if there is some way around this so I can make this work.
In JSP / HTML, I want to restrict the size of file being uploaded.
<input type="file" name="myfile"/>
If the user trying to upload a file size bigger than some value say 5MB, i want to give mesage to the user. I don't want to wait till the file gets uploaded to server and then validate the file size. I am looking for client side validation. Can it be done using scripting language or any other way?
Need a solution for this in Internet Explorer. I got a solution using ActiveX control:
var myFSO = new ActiveXObject("Scripting.FileSystemObject"); var filepath = document.getElementById('myfile').value; var thefile = myFSO.getFile(filepath); var sizeInBytes = thefile.size;
But ActiveX controls are not allowed in our application. Is there any alternative way for this?
I'm currently generating some tooltips to display data for certain items in a game. The tooltips and stats work great, however, for certain items, the tooltip gets long and will extend pass the viewable range for the user.
Here are the links: test page: [URL] javascript: [URL] css (for hover div only): [URL]
If you hover over the links of items (like villages, barracks, etc.) a tooltip will pop up to show you the stats. But if you notice, for items like castles, the tooltip can extend past the viewable range for the user.
Does anyone have code to restrict input of a singli quote and a backslash in input field? I need to make sure this code works in IE, FF, Opera. Well, all major browsers
Is there anyway of restricting the amount of webpages open. I would like users of a site only to beable to have two pages (from the site i am talking about) open at anyone time.