Dynamic Context Menu using HTML+TIME
 <HTML  xmlns:t ="urn:schemas-microsoft-com:time"
<HTML  xmlns:t ="urn:schemas-microsoft-com:time" xmlns:v = "urn:schemas-microsoft-com:vml"  >
xmlns:v = "urn:schemas-microsoft-com:vml"  >   <HEAD>
<HEAD> <?IMPORT namespace="t" implementation="#default#time2">
<?IMPORT namespace="t" implementation="#default#time2"> <STYLE>
<STYLE> v:* {  BEHAVIOR: url(#DEFAULT#VML)}
v:* {  BEHAVIOR: url(#DEFAULT#VML)} BODY         {font-family:arial;font-size:80%}
BODY         {font-family:arial;font-size:80%} .time        {behavior: url(#default#time2)}
.time        {behavior: url(#default#time2)} .box         {position:absolute;top:100;left:100;width:150px;height:22px;
.box         {position:absolute;top:100;left:100;width:150px;height:22px; padding:5px;padding-left:15px;display:none;cursor:hand;font-family:arial;}
             padding:5px;padding-left:15px;display:none;cursor:hand;font-family:arial;} </STYLE>
</STYLE>
 <SCRIPT>
<SCRIPT> // Function is used to animate the menu box movement.
// Function is used to animate the menu box movement. function moveBox(){
function moveBox(){ var mouseLeft = null;
    var mouseLeft = null; var mouseTop = null;
    var mouseTop = null; // Make the menu boxes visible
    // Make the menu boxes visible oBox.style.display='block';
    oBox.style.display='block'; oBox2.style.display='block';
    oBox2.style.display='block'; oBox3.style.display='block';
    oBox3.style.display='block'; // Retrieve x and y coordinates of the mouse click
    // Retrieve x and y coordinates of the mouse click mouseLeft=event.clientX;
    mouseLeft=event.clientX; mouseTop=event.clientY;
    mouseTop=event.clientY; ////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////     // Two t:ANIMATE elements are used for each menu box to control the
    // Two t:ANIMATE elements are used for each menu box to control the  // movement of each box. One t:ANIMATE element controls the x-coordinate
    // movement of each box. One t:ANIMATE element controls the x-coordinate // animation and the other controls the y-coordinate animation. The "to"
    // animation and the other controls the y-coordinate animation. The "to"  // properties of the t:ANIMATE elements are set to a value relative to
    // properties of the t:ANIMATE elements are set to a value relative to  // the respective x and y coordinates of the mouse click. This ensures
    // the respective x and y coordinates of the mouse click. This ensures // that the menu boxes animate to the correct location. To begin the
    // that the menu boxes animate to the correct location. To begin the  // animation, the t:ANIMATE elements are started on the time line using
    // animation, the t:ANIMATE elements are started on the time line using // the "beginElement()" method.
    // the "beginElement()" method. /////////////////////////////////// ////////////////////////////////////////
/////////////////////////////////// //////////////////////////////////////// // Code for top menu box animation.
    // Code for top menu box animation. leftMove.to=mouseLeft;
    leftMove.to=mouseLeft; topMove.to=mouseTop;
    topMove.to=mouseTop; leftMove.beginElement();
    leftMove.beginElement(); topMove.beginElement();
    topMove.beginElement(); // Code for middle menu box animation.
    // Code for middle menu box animation. leftMove2.to=mouseLeft;
    leftMove2.to=mouseLeft; topMove2.to=mouseTop + 29; // notice that y-coordinate is offset
    topMove2.to=mouseTop + 29; // notice that y-coordinate is offset leftMove2.beginElement();
    leftMove2.beginElement(); topMove2.beginElement();
    topMove2.beginElement(); // Code for bottom menu box animation.
    // Code for bottom menu box animation. leftMove3.to=mouseLeft;
    leftMove3.to=mouseLeft; topMove3.to=mouseTop + 58;
    topMove3.to=mouseTop + 58; leftMove3.beginElement();
    leftMove3.beginElement(); topMove3.beginElement();
    topMove3.beginElement(); }
} // Function is used to hide the menu when clicked.
// Function is used to hide the menu when clicked. function closeMenu(){
function closeMenu(){ oBox.style.display='none';
    oBox.style.display='none'; oBox2.style.display='none';
    oBox2.style.display='none'; oBox3.style.display='none';
    oBox3.style.display='none'; }
} </SCRIPT>
</SCRIPT> </HEAD>
</HEAD> <!-- The "oncontextmenu" event is used to make the menu become visible and animate. -->
<!-- The "oncontextmenu" event is used to make the menu become visible and animate. --> <BODY oncontextmenu="moveBox(); return false;" onclick="closeMenu();">
<BODY oncontextmenu="moveBox(); return false;" onclick="closeMenu();"> <H2>Dynamic Context Menu using HTML+TIME</H2>
<H2>Dynamic Context Menu using HTML+TIME</H2> <H2>点右键试试,在不同的位置点右键</H2>
<H2>点右键试试,在不同的位置点右键</H2>
 <!-- Here are the menu blocks. Notice the vml behavior is attached to them,
<!-- Here are the menu blocks. Notice the vml behavior is attached to them,  which enables the rounded corners of the menu blocks. -->
which enables the rounded corners of the menu blocks. --> <v:ROUNDRECT ID="oBox" CLASS="box" ARCSIZE="90923f" STROKEWEIGHT="2" fillColor='#ffcccc'
<v:ROUNDRECT ID="oBox" CLASS="box" ARCSIZE="90923f" STROKEWEIGHT="2" fillColor='#ffcccc'  onmouseover="this.fillColor='#ffcc00'" onmouseout="this.fillColor='#ffcccc'"
onmouseover="this.fillColor='#ffcc00'" onmouseout="this.fillColor='#ffcccc'" onclick="closeMenu(); alert('hello!');">
onclick="closeMenu(); alert('hello!');"> Home</v:ROUNDRECT >
Home</v:ROUNDRECT > 
         <v:ROUNDRECT ID="oBox2" CLASS="box" ARCSIZE="90923f" STROKEWEIGHT="2" fillColor='#ffcccc'
<v:ROUNDRECT ID="oBox2" CLASS="box" ARCSIZE="90923f" STROKEWEIGHT="2" fillColor='#ffcccc'  onmouseover="this.fillColor='#ffcc00'" onmouseout="this.fillColor='#ffcccc'"
onmouseover="this.fillColor='#ffcc00'" onmouseout="this.fillColor='#ffcccc'" onclick="closeMenu(); alert('hello 2!');">
onclick="closeMenu(); alert('hello 2!');"> Articles</v:ROUNDRECT >
Articles</v:ROUNDRECT > 
         <v:ROUNDRECT  ID="oBox3" CLASS="box" ARCSIZE="90923f" STROKEWEIGHT="2" fillColor='#ffcccc'
<v:ROUNDRECT  ID="oBox3" CLASS="box" ARCSIZE="90923f" STROKEWEIGHT="2" fillColor='#ffcccc'  onmouseover="this.fillColor='#ffcc00'" onmouseout="this.fillColor='#ffcccc'"
onmouseover="this.fillColor='#ffcc00'" onmouseout="this.fillColor='#ffcccc'" onclick="closeMenu(); alert('hello 3!');">
onclick="closeMenu(); alert('hello 3!');"> Contacts</v:ROUNDRECT >
Contacts</v:ROUNDRECT >  <!-- Here are the t:ANIMATE elements which control the animation of the
<!-- Here are the t:ANIMATE elements which control the animation of the menu blocks. Notice that the "DUR" attribute values are different for each
menu blocks. Notice that the "DUR" attribute values are different for each pair of elements. This causes the blocks to move at different rates and follow
pair of elements. This causes the blocks to move at different rates and follow one another. -->
one another. --> <t:ANIMATE
<t:ANIMATE  ID="leftMove"
        ID="leftMove"  TARGETELEMENT="oBox"
        TARGETELEMENT="oBox"  ATTRIBUTENAME='left'
        ATTRIBUTENAME='left'  BEGIN="indefinite"
        BEGIN="indefinite"  DUR=".15" to=""
        DUR=".15" to=""  DECELERATE="1"
        DECELERATE="1" FILL="freeze"
        FILL="freeze" onend="this.from=this.to"/>
        onend="this.from=this.to"/> <!-- Note that when each t:ANIMATE element ends, its "from" property is
<!-- Note that when each t:ANIMATE element ends, its "from" property is  updated to the coordinate that the animation ends at. Thus, upon the next
updated to the coordinate that the animation ends at. Thus, upon the next animation, the menu starts its animation from the new location  -->
animation, the menu starts its animation from the new location  --> <t:ANIMATE
<t:ANIMATE  ID="topMove"
        ID="topMove"  TARGETELEMENT="oBox"
        TARGETELEMENT="oBox"  ATTRIBUTENAME='top'
        ATTRIBUTENAME='top'  BEGIN="indefinite"
        BEGIN="indefinite"  DUR=".15" to=""
        DUR=".15" to=""  DECELERATE="1"
        DECELERATE="1" FILL="freeze"
        FILL="freeze" onend="this.from=this.to"/>
        onend="this.from=this.to"/> <t:ANIMATE
<t:ANIMATE  ID="leftMove2"
        ID="leftMove2"  TARGETELEMENT="oBox2"
        TARGETELEMENT="oBox2"  ATTRIBUTENAME='left'
        ATTRIBUTENAME='left'  BEGIN="indefinite"
        BEGIN="indefinite"  DUR=".3" to=""
        DUR=".3" to=""   DECELERATE="1"
        DECELERATE="1" FILL="freeze"
        FILL="freeze" onend="this.from=this.to"/>
        onend="this.from=this.to"/> <t:ANIMATE
<t:ANIMATE  ID="topMove2"
        ID="topMove2"  TARGETELEMENT="oBox2"
        TARGETELEMENT="oBox2"  ATTRIBUTENAME='top'
        ATTRIBUTENAME='top'  BEGIN="indefinite"
        BEGIN="indefinite"  DUR=".3" to=""
        DUR=".3" to=""   DECELERATE="1"
        DECELERATE="1" FILL="freeze"
        FILL="freeze" onend="this.from=this.to"/>
        onend="this.from=this.to"/> <t:ANIMATE
<t:ANIMATE  ID="leftMove3"
        ID="leftMove3"  TARGETELEMENT="oBox3"
        TARGETELEMENT="oBox3"  ATTRIBUTENAME='left'
        ATTRIBUTENAME='left'  BEGIN="indefinite"
        BEGIN="indefinite"  DUR=".6" to=""
        DUR=".6" to=""   DECELERATE="1"
        DECELERATE="1" FILL="freeze"
        FILL="freeze" onend="this.from=this.to"/>
        onend="this.from=this.to"/> <t:ANIMATE
<t:ANIMATE  ID="topMove3"
        ID="topMove3"  TARGETELEMENT="oBox3"
        TARGETELEMENT="oBox3"  ATTRIBUTENAME='top'
        ATTRIBUTENAME='top'  BEGIN="indefinite"
        BEGIN="indefinite"  DUR=".6" to=""
        DUR=".6" to=""   DECELERATE="1"
        DECELERATE="1" FILL="freeze"
        FILL="freeze" onend="this.from=this.to"/>
        onend="this.from=this.to"/>
 </BODY>
</BODY> </HTML>
</HTML>
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号