Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 24th, 2006, 01:37 PM
Authorized User
Join Date: Jun 2003
Location: Richmond, VA, USA.
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to erobb Send a message via Yahoo to erobb
Default ie7 keycode, event handlers

I have a peice of code that I am using to stop the enter key (return) from submitting a form. I wanted to make a modification to this code so that users were not allowed to paste elements into a form. Because its a time entry form I am using on keydown ect to auto calculate totals and cnrl-v stops my function from being fired.

The Nav branch of the code works great in FF but I cant get it working in ie 7. Since I cant revert to ie 6 to see if its specific to 7 Im not sure if the handler is not firing because of the new version or my logic is just wrong for ie.

I know people will still be able to go edit>paste but because of the nature of the form I think it will not be an issue as it will certainly be quicker to enter 8 numbers than do edit>paste 8 times

function kH(e) { //function is not called in IE when a control - v combination is used
    var nav = window.Event ? true : false;
    var pK = document.all? window.event.keyCode:e.which;

        if(e.ctrlKey == true){
            return false;
        if(e.target.type != 'textarea'){
            return pK != 13;

        alert(event.ctrlKey + 'hello');
        if(event.ctrlKey == true){
            return false;
            return pK != 13;

document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);

Thanks Earl

Similar Threads
Thread Thread Starter Forum Replies Last Post
Event handlers jwebb Visual Basic 2005 Basics 1 June 25th, 2007 08:44 PM
Event handlers does not work after some changes geetageetageeta ASP.NET 2.0 Basics 0 March 6th, 2006 04:19 AM
Conflicting Event Handlers chp Excel VBA 3 February 24th, 2006 03:00 PM
Using Multiple Event Handlers in Excel chp Excel VBA 4 February 15th, 2006 06:25 PM
Dynamically change event handlers oranginalab Javascript How-To 2 July 31st, 2003 10:11 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.