AltKey, ctrlKey, shiftKey, altkeyctrlkey

Source: Internet
Author: User

AltKey, ctrlKey, shiftKey, altkeyctrlkey

<1>

<Html xmlns = "http://www.w3.org/1999/xhtml"> 



How does JavaScript ie prevent event bubbling?

The IE event is different from other standard DOM events, and the bubble mechanism of different browser events is also different.

IE:
Window. event. cancelBubble = true; // stop bubbling
Window. event. returnValue = false; // block the default behavior of the event

Firefox:
Event. preventDefault (); // cancel the default event behavior.
Event. stopPropagation (); // prevents event Propagation

You can try other browsers on your own...

Hi.baidu.com/..c.html
------------------------------------------------------------------

The following content can be viewed:

Event Represents the status of an event and is responsible for event processing. Its Attributes and methods can help us complete many operations that interact with users;

I. main attributes and methods of Event objects

1. type: the type of the event, which is a string without the "on" prefix in the HTML Tag attribute. For example, "Click" indicates the Click event.

2. srcElement: The Event source, which is the element of the event. For example, <a onclick = "check ()"> </a> a is the source of the event, that is, the srcElement of the event. (Target is not used in IE)

3. button: Declares the mouse key pressed, which is an integer. 0 indicates no buttons, 1 indicates the left mouse button, 2 indicates the right mouse, and 4 indicates the middle mouse key. If you press Multiple mouse keys, add these values together, so 3 indicates that the left and right keys are pressed simultaneously.

4. clientX/clientY: refers to the horizontal and vertical coordinates of the mouse when an event occurs. The return value is an integer. Their values are generated relative to the upper left corner of the inclusive window.

5. offsetX/offsetY: the position of the mouse pointer relative to the source element. You can determine which pixel of the Image object to click.

6. altKey, ctrlKey, and shiftKey: as the name suggests, these attributes indicate whether Alt, Ctrl, or Shift keys are simultaneously held when a mouse event occurs, and a Boolean value is returned.

7. keyCode: return the code of the key and the Unicode characters of the keypress event when the keydown and keyup events occur. For example, event. keyCode = 13 indicates that the Enter key is pressed;

8. fromElement and toElement refer to the document elements that the mouseover event has moved, and the former refer to the document elements that the mouse moves to in the mouseout event.

9. cancelBubble: A boolean attribute. When it is set to true, the Stop event is further flushed to an element of the inclusion level, which is used to detect whether the event control of the upper layer element is accepted. True indicates that the event is not controlled by the upper element, and false indicates that the event is allowed by the upper element.

10. returnValue: a boolean attribute. When it is set to false, it can prevent the browser from executing the default event action, which is equivalent to <a href = "#" onclick = "ProcessMethod (); return false; "&#...... remaining full text>

Prohibit right-click selection, pasting, shift, and ctrl

<Script language = "JavaScript">
<! --
Function key (){
If (event. shiftKey ){
Window. close ();}
// Disable shift
If (event. altKey ){
Window. close ();}
// Disable alt
If (event. ctrlKey ){
Window. close ();}
// Disable ctrl
Return false ;}
Document. onkeydown = key;
If (window. Event)
Document. captureEvents (Event. MOUSEUP );
// Swordmaple javascript article.
// From www.jx165.com
Function nocontextmenu (){
Event. cancelBubble = true
Event. returnValue = false;
Return false ;}
Function norightclick (e ){
If (window. Event ){
If (e. which = 2 | e. which = 3)
Return false ;}
Else
If (event. button = 2 | event. button = 3 ){
Event. cancelBubble = true
Event. returnValue = false;
Return false ;}
}
// Disable right-click
Document. oncontextmenu = nocontextmenu; // for IE5 +
Document. onmousedown = norightclick; // for all others
// -->
</Script>
<Body onselectstart = "return false"; onpaste = "return false";>
Select a character and try 1010110
<Input size = 30>
<! -- Onselectstart prohibit onpaste from pasting -->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.