Possible To Do A CTRL-z (undo) In On-click Event
Sep 29, 2010is it possible to do a CTRL-z (undo) in a onclick event ?
View 3 Repliesis it possible to do a CTRL-z (undo) in a onclick event ?
View 3 RepliesI am writing a callback functions that fit into a framework. Unfortunately, the framework does not provide any means of getting the initial onclick event. So, I tried doing the following to see if the ctrl key was pressed:
var ctrl=(window.event&&window.event.ctrlKey);
This didn't work. Is there a way to know if the ctrl key was pressed after the fact?
I was wondering what code I would use to implement a function while the user holds either shift or control while clicking on an element.
View 9 Replies View RelatedI want to capture the event when the <ctrl> key is pressed.
View 3 Replies View RelatedI would like to create a plugin that I can put before a click event on a button. The click event should occur if the user's time on the page hasn't expired. The plugin should check the user's time, and then stop the click event if the time has expired. With the plugin, I'm essentially putting two click events on the same button, as I need to check the expiration when the button is clicked. The plugin is working on my test page, but I'm afraid that this is contingent on an arbitrary ordering of the click events by jQuery. If I have my click event chained after my plugin, can I be assured that the plugin would always stop the click event if the time is expired? Or could jQuery execute the click event before the time gets checked?
(function( $ ){
$.fn.checkExpiration = function(
$this = $(this);
return this.each(function(){3
[Code].....
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.
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:
<!--
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>
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.
I want to call the click event of the link (anchor tag) on the click of the button. I used this code below in the click event of button to call links click event and it works fine in IE.
document.getElementById('linktag').click();
But, this doesn't work in Firefox. I googled a bit and found that in firefox, you have to do something more to achieve this behaviour. So, I ended up doing this on button click to work in firefox:
var link=document.getElementById('linktag');
var e = document.createEvent('MouseEvents');
e.initEvent(
[code]....
The above code does the click on link when I click on the button. But my problem now is that I have defined a link as
<a href="mailto:abc@xyz.com?subject=abc&body=email body">email </a>
and when click is called and mailto links opens my email client, it somehow ignores the subject and body parameters of the link. It works properly when i actually click a link element. but it doesn't work when i simulate the click event by code written above. above dispatching event code somehow ignores the link parameters?
How can I give a click on a link when it is just created and added to DOM?
None of this works:
function openProfilePage(profile){
$('#profile-link').remove();
var link = $('<a/>').attr({'href':'profile.php?user='+profile, 'target':'_blank', 'id':'profile-link'}).css({'top':'-200px','left':'-300px', 'position':'absolute'}).html(profile);
[Code]...
I have an object that has a click event I'm trying to trigger. However in the click event I have the following if statement:
if(event.button != 0){return true;}
This if statement allows right clicks to go through and activate but it also prevents me from triggering the event. Any ideas on how to prevent this? If I remove the if statement from the first click function everything works as intended.Here's my example code based off of the trigger event examples:
<!DOCTYPE html>
<html>
<head>
[code]....
This is just a page swapping images on the mouseover event, but i want to remove the mouseover events from all links when the the on click function is triggered, this is the html code,
View 3 Replies View RelatedJQuery click event fires on second click but not on first. I have had this happend before some time ago.
View 6 Replies View RelatedI create buttons from an array of objects that such as:
buttons = [{ text: "button 1", action: 1}, {text: "button 2", action: 2}];
I then loop thru the array to assign the text and bind the click event after having created the buttons with IDs of "button_<index>".
for( var index in buttons ) {
$("#button_"+index).html ( buttons[index].text )
.click( function() { clickButton( buttons[index].action ) } );
}
The text appears correctly in the button, but every button defined only fires the list bound click, in this example the action equal to'2'whether I push "Button 1" or "Button 2".My actual case has four buttons, all firing the event for the fourth button.I've tried not chaining the .click(), going thru the loop twice once for the .html and once for the .click, neither of which made a difference. If I hard code each button .click, it works fine.
Is there any way to capture the action Ctrl+N (whether it in a hidden
button or keyword - doesn't matter) in html, javascript or php?
How can I detect the press of CTRL + V in an input of type text?
View 4 Replies View RelatedI am using the following code for disabling Ctrl-N in IE7. It disables the Ctrl-N feature of IE which opens a new window containing the same page as the 'active' window. The code works great (at first glance). However, I noticed that, if you click anywhere inside the browser window and THEN press Ctrl-N, the new window will open. If you don't click anywhere inside the window, the following code works. Can anyone see an improvement to the following code so that clicking inside the browser window doesn't bypass the javascript?
View 2 Replies View RelatedI would like to bind a set of data inside a repeater and be able to use the selector to select 1 or more then 1 values?
View 8 Replies View RelatedI am working on copying from one listbox to another. The value should not be removed from first list box. I am trying to select multiple values using ctrl key for copying. can someone give some idea or sample code for this.
View 6 Replies View RelatedCan I disable the ctrl + f funtionality in the browsers?
View 3 Replies View RelatedUsing jQuery, how do I make a function to execute when users press Ctrl+Q? Or other combinations of Ctrl and a key.
View 3 Replies View RelatedI would like to do this WITHOUT jQuery.
I have tried to get an event listener to listen for when the user presses Control-D on their keyboard. This would trigger a confirm delete function - if you've ever used QuickBooks Ctrl-D is the command that does this and this is a financial application.
Problem is that in FireFox, Ctrl-D means bookmark the page and this window pops up. I want to "return false" before this happens.
On this subject I would also like to take over Ctrl-C and Ctrl-V eventually but with Ctrl-D it will work for anything. here is what I have. Again, IT WORKS, but doesn't stop the natural event (bookmark page) fromhappening:
Code:
function AddOnkeypressCommand(strCommand){
//---- version 1.0, by , last edit 2004-12-14
//add to array of commands:
m_onkeypressCmds[m_onkeypressCmds.length] = strCommand;
[Code].....
I wish for my users to retype their email address instead of the copy and paste method to ensure they have typed it correctly both times.
How could this be done, would it be Javascript ?
I want to disable a function when a user is pressing control or command using Javascript. Is this at all possible? My reason for doing this is because I recently implemented lightbox to my script, but I still want users to be able to open the image in a new tab by just clicking control or command when clicking the image rather than opening it in lightbox (which it does).
View 1 Replies View RelatedI'm working on controlling a windows media player I'm trying to figure out how to control it with keys like CTRL+SHIFT+P to play it. The problem is that I don't know how to capture all three at the same time.
I'm ONLY supporting IE because that's what the client only want's supported. I have been reading through the forums but nothing about capturing both CTRL+another key or SHIFT+another key.