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:
View 3 Replies
ADVERTISEMENT
Apr 3, 2011
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
[Code]....
View 3 Replies
View Related
Jul 23, 2005
I`m writing a javascript regex tester (IE 6 only) and would like to include
an undo button for a text input field.
I want it to handle individual keystrokes, pasting and drop, and also
text added by clicking various buttons.
I have tried a LOT of handler combinations and fancy conditionals to
make it work perfectly, and I`m ALMOST there.
View 3 Replies
View Related
Jun 8, 2004
<!--
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
function init(){
w_isiwig = document.getElementById("wisiwig");
w_isiwig.contentEditable = true;
w_isiwig.onkeyup = HandleKeys;
b_ackup[0] = w_isiwig.innerHTML;
}
function HandleKeys(evt) {//events to write to backup
//
if (event) {
switch (event.keyCode) {
case 32:
BACKUP();
break;
case 8:
BACKUP();
break;
case 13:
BACKUP();
break;
case 46:
BACKUP();
break;
default:
return;
}
}
}
function BACKUP(){
if (flag){// action if undo was clicked
var removed= b_ackup.splice(flag,b_ackup.length - flag);
for (var i = 0; i < removed.length; i++) {
delete removed[i];//delete obsolete array items
}
b_ackup[b_ackup.length] = w_isiwig.innerHTML;
undo_pos = b_ackup.length - 1;
flag = false;
w_isiwig.focus();
}
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++){
e+= 'Backup item '+i+':'+b_ackup[i]+'
'
}
document.getElementById('bup_a').value=e;
}
</script>
<title>undo-redo</title>
</head>
<body id = "body" onload= "init();">
<p><b>undo/redo</b> <br>
development version: for <b>IE</b> only<br>
Backup written by <b>'onkeyup'</b> event(space,back,return,del), or
<b>'add to backup'</b> button. </p>
<div id="menu">
<a href="#" onclick='BACKUP();return false'>[add to backup]</a>
<a href="#" onclick='setTimeout("undo()",10)'>[undo]</a>
<a href="#" onclick='setTimeout("redo()",10)'>[redo]</a>
<a href="#" onclick='look()'>[view backup-data]</a> </div>
<div id="wisiwig">Type text: </div>
Backup Array Data: <br>
<div id="bup">
<textarea id="bup_a" name="bup_a" cols="80" rows="6"></textarea>
</div>
</body>
</html>
View 8 Replies
View Related
Sep 29, 2010
is it possible to do a CTRL-z (undo) in a onclick event ?
View 3 Replies
View Related
Sep 6, 2010
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.
View 1 Replies
View Related
Sep 28, 2006
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.
View 2 Replies
View Related
Feb 23, 2005
Is it possible to use the command:
document.execCommand("InsertUnorderedList")
to specify what type of unordered list, or to use css to specify, what type of unordered list you want?
View 2 Replies
View Related
Jul 18, 2011
Does anybody know what's the use of the execCommand() function?? Also, is it used to add tags in textboxes??
View 6 Replies
View Related
Jul 20, 2005
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:
"<a title='User inputed tooltip'>Selected Text</a>".
Any ideas?
View 1 Replies
View Related
Jul 4, 2010
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:
function get(editid) {
// IE
if(document.frames[editid].document) return document.frames[editid].document;
else return document.getElementById(editid).contentDocument;
}
[Code]....
The xC (execute command) function is not working! I've tried so much.
View 2 Replies
View Related
Oct 8, 2010
I want to remove link. How to do that using execCommand()
View 1 Replies
View Related
Aug 17, 2003
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?
View 3 Replies
View Related
Dec 21, 2010
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.
View 1 Replies
View Related
Apr 7, 2009
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?
View 7 Replies
View Related
May 30, 2006
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.
View 1 Replies
View Related
Jan 18, 2006
I have a textfield where i would like the user to input only Y or N.
can somebody tell me how can i restrict the user from entering any other character, number or special character.
View 10 Replies
View Related
Feb 14, 2007
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?
View 3 Replies
View Related
Jun 30, 2010
I am having a table with rows created using a button click event. While adding rows to the table, I create drop dowlist using
Code:
objVehicles = document.createElement("<SELECT class='dropdownbox' id=Vehicles"+objAlertRowId+" name=Vehicles"+objAlertRowId+" STYLE='width:148px'; onchange='setDataChanged();toggleEditButton(" + objAlertRowId+ ",this.value);' >");
objNewRow.cells.item(3).appendChild(objVehicles);
And the output will be like the attached screen shot.
The control name as Vehicles0,Vehicles1 and so on Now I want to restrict that the the user select no duplicates from the List.
What logic I can implement ?
View 2 Replies
View Related
Jul 6, 2006
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.
View 3 Replies
View Related
Sep 13, 2009
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.
<script type="text/javascript">
function myEye() {
document.coordform.submit();
}
</script>
<form action='store.php' method=post name="coordform"> .....
View 4 Replies
View Related
Jun 14, 2011
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?
View 3 Replies
View Related
Oct 31, 2009
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.
View 1 Replies
View Related
Feb 11, 2006
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
View 6 Replies
View Related
Feb 19, 2007
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.
View 1 Replies
View Related
Nov 8, 2009
I am very able to restrict char length by using substr() but this means that in some cases the word gets cut off in the middle of it.
How can I restrict the char length to the nearest word.
This is where I got to and then went blank?
Code:
if(comparename.length > 18){
if(comparename.substr(0,18) != ' '){
for(var tzx=0;tzx<comparename.length;tzx++){
while(comparename.substr(0,(18-tzx)) != ' '){
[Code]....
View 3 Replies
View Related