JS implementation of its own definition of the right mouse button-------Day45

Source: Internet
Author: User

Another weekend, but in fact, this should be considered a week in foreign countries, no matter how to say, today is in rest, relax my tense nerves, relax me some tired spirit, last night to crack a headache, as if all the data in the brain literally dancing, accompanied by a burst of nausea, then the daughter-in-law to frighten, I really do not know how Kobe Bryant every day to see the four o'clock in the morning sun, this constitution can not be said, and there is a point is to have to say that the body is really the root of all, friendship suggest friends or good exercise body, I also want to exercise well.

Recall this week, the project leader of a sentence to me very big touch, the exact words I can not remember how to say, probably mean to say: no matter how much you will, you have to use the is your. In fact, that sentence at the time of the situation should be some far-fetched, and even said is not correct, but still let me sigh unceasingly. Looking back at the initial job search, write on the resume what will be, go to interview ask you understand what, and then test that, but to the work is not necessarily on the practical, and even some when you use on the time, you only find that you will actually still useless, but also to learn, this and my initial work experience is different, At that time, a piece of the area, in their own area to how to toss on how to toss, the problem to overcome the good, and this inertial way of thinking let me in the industry this is initially painful, to this will be as if suddenly want to clear the same: do everything to abide by the rules, and the existence of rules may be considered to bind their own But the overall progress of the project can be more convenient, because the rules in that, a project team are guarding this specification, in the integration of the time is much simpler.

Of course, it is clear that very much, are opinion, it is not in this disgraced, in fact, the assumption is that the school is to learn the knowledge, the company is to let people learn how to use, presumably this is the student's time we always in the feeling of learning something useless reason, after all, the internal strength of thousands of years, no moves are false.

Ramble said very much, the words of simplicity turn, today to record JS to their own definition of the right mouse button, the same first to break down its implementation principle:

1, Shielding right-click Default event; (At one point I thought the default event was changed)

2, to a UL of the hidden; (This I was also pedantic to think that it is worth the operation of the Div, Khan)

3, the right mouse button to make the response, showing the hidden ul;

4, the mouse again after the Click, UL again is hidden

In this way, what we need to do is not simply very much, first on the code:

HTML section

<ul id= "Testright" style= "width:100px;background-color:yellow;position:absolute;z-index:100;" >    <li><a href= "#" > Start </a></li>    <li><a href= "#" > Pause </a></li >    <li><a href= "#" > Bye </a></li></ul>
JavaScript section:

Window.onload=function () {var Forright=document.getelementbyid ("Testright");//Get the object, now too familiar with forright.style.display= "None"; var title=forright.getelementsbytagname ("Li"); for (Var i=0;i<title.length;i++) {title[i].onmouseover= function () {this.classname= "active";//actually we can call other events here};title[i].onmouseout=function () {// Here is also a mouse two events bar This.classname= "";};} Document.oncontextmenu=function (Event) {//This is the key point of implementation var event=event| | window.event;//, this is not a problem. forright.style.display= "block"; forright.style.left=event.clientx+ "px"; forright.style.top=event.clienty+ "px";//mouse coordinates AH return false;//here return false is to block the default event};d ocument.onclick=function () {/ /Just for a more image imitation Ah forright.style.display= "none";};
Let's take a look at the key points of today's record: Document.oncontextmenu This event returns false to block the default event, assuming we don't write anything else, just write return in this event, as if it were the following

Document.oncontextmenu=function () {     return false;}
in this case, clicking the right button will not appear in any response whatsoever. Then return to see the whole event application, as if in addition to this event, the other is more familiar with the event, can be the event of this integration is always lacking, the key is the idea is creative bar, just first no matter where more, first the whole bar, but to seek to read 3,000, not to write to just ask Yin. Tie horse, tie horse, tie horse ...


In fact, when I first saw "Harry Potter", I was particularly envious of his magic broom, every day to take care of cleaning, reading is also looking at the broom and so on, as if to think of ancient swordsman, can be so pious. I am very fortunate, so long ago found oneself willing to struggle of things, I would like to take a pilgrimage heart, forward ....





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.