Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    hi all, ive just found this script and it works well! However i dont want the link function there so can someone please delete what needs deleting so it still works cause when i delete the link parts it stops working...

    I only want to click a button and an image swops which is what it does. But this code also includes a onclick of the image it opens a URL and i need that part deleting from all images.. Its embeded in the Jscript..

    any help will be greatly appreciated!

    Cheers then
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
    <head xmlns="http://www.w3.org/1999/xhtml">
    <title>Js Testing</title>
    <style type="text/css">
    button    {
        border: solid 1px #000000;
        text-decoration:none;
        color:#000000;
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 10px;
        font-style: normal;
        font-weight: normal;
        font-variant: normal;
        padding:4px;
        background-color:#99FF66;
        float:left;
        margin-left:5px;
        margin-top:10px;
    }
    button:hover    {
        border: solid 1px #333333;
        text-decoration:none;
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 10px;
        font-style: normal;
        font-weight: normal;
        font-variant: normal;
        padding:4px;
        background-color:#00CC33;
        float:left;
        margin-left:5px;
        margin-top:10px;
    
    }
    </style>
    </head>
    <body>
    <div id="header">
    <h1>Javascript Testing</h1>
    </div>
    <script type="text/javascript">17.18
     
    /*Image data: src, link */
    var data = [
        {src: "images/random2.jpg", link: "http://google.com"},
            {src: "images/random3.jpg", link: "http://yahoo.com"},
                {src: "images/random4.jpg", link: "http://chapo.co.cc"}
                ];
                /* This function will be called when button is clicked.*/
                function buttonClick(index) {
                    if(!data[index]) {
                            alert("No data found at index : " + index);
                                    return;
                                        }
                                            var src = data[index].src;    var link = data[index].link;
                                var img = document.images.im1;
                                        /* Changing image attributes */
                                            img.src = src;    img.onclick = function() {        window.open(link);
                                                };}
                                                </script>
                                                <div>
                                                <img src="images/random1.jpg" name="im1" onclick="window.open('http://google.com')"/><br/>
    
                                                <button onclick="buttonClick(0);">1</button>
                                                <button onclick="buttonClick(1);">2</button>
                                                <button onclick="buttonClick(2);">3</button>
                                                </div>
                                                </body>
                                                </html>
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:24 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com