dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: Unclickable button

  1. #1
    Join Date
    Feb 2014
    Posts
    16

    Unclickable button

    Hi friends,

    Is someone knows how to write a code for an Unclickable button like in the attached example ?
    http://gamersite.weebly.com/the-unclickable-button.html

    thanks,

    Benny

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,866
    Right click on the web page.
    View source.
    Wade through the code and various .js files to see how it is done.
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Feb 2014
    Posts
    16
    Quote Originally Posted by \\.\ View Post
    Right click on the web page.
    View source.
    Wade through the code and various .js files to see how it is done.
    hi,
    thanks, Do you know where can I get plug-in which make this effect ?

    benny

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,866
    It is in the scripting of the site, looks like they are using the prototype.js library.
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  5. #5
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,697
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function CatchMe(o){
     var w=o.offsetWidth;
     var h=o.offsetHeight;
     var mx=o.parentNode.offsetWidth;
     var my=o.parentNode.offsetHeight;
     if (mx>w*2&&my>h*2){
      var x=o.offsetLeft+w/2; // the x position of the center of the button
      var y=o.offsetTop+h/2   // the y position of middle center of the button
      var nx=Math.random()*(mx-w)+w/2; // the new x position
      var ny=Math.random()*(my-h)+h/2; // the new y position
      // math.abs converts negative numbers to positive numbers
      while (Math.abs(nx-x)<w||Math.abs(ny-y)<h){ // if the new x - old x is < width or if the new y - old y is < height recalculate
       nx=Math.random()*(mx-w)+w/2;
       ny=Math.random()*(my-h)+h/2;
      }
      o.style.left=nx-w/2+'px';
      o.style.top=ny-h/2+'px';
     }
    }
    /*]]>*/
    </script></head>
    
    <body>
     <div style="position:relative;width:400px;height:300px;border:solid red 1px;" >
      <div style="position:absolute;left:150px;top:150px;width:100px;height:50px;background-Color:red;" onmouseover="CatchMe(this);" ></div>
    
     </div>
    </body>
    
    </html>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  6. #6
    Join Date
    Feb 2014
    Posts
    16
    Thank you very much !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles