Welcome to TalkGraphics.com
Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Random link

  1. #11
    Join Date
    Sep 2000
    Location
    Bracknell, UK
    Posts
    8,659

    Default Re: Random link

    There is a particular reason for the random page.

    What is that reason?

  2. #12
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,814

    Default Re: Random link

    Quote Originally Posted by siran View Post
    As Acorn suggested you can use a random number, just specify something like
    Code:
    javascript:window.location="http://example.com/"+((Math.random()<0.5)?"link1":"link2")+".htm";
    in the "Link to Web or Email address" property.
    Siran, I have added to your example with links to other website pages: random link (refined).xar

    Any click on the image on the page picks test1.htm / test2.htm; only the Home button returns to the index.htm page.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  3. #13
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,916

    Default Re: Random link

    I can follow a lot of this but what always trips me up is how to intergrate js within Xara placeholders or buttons.

    For example here is a nice script that sets up an array of url's that uses the length of the array to set up the number of url options.

    How would this be intergrated into a Xara page?

    Source:
    http://stackoverflow.com/questions/3...andom-redirect

    var sites = [
    'http://www.dilbert.com',
    'http://stackoverflow.com',
    'http://Starwars.com'
    ];
    var target = Math.floor(Math.random() sites.length);
    window.location = sites[target];

    So when your site collection grows you don't need to alter the code. You could even pack it into a function:

    function goRandomSite(sites) {
    var target = Math.floor(Math.random() sites.length);
    window.location = sites[target];
    }
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  4. #14
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    927

    Default Re: Random link

    Egg, in this example you could put
    Code:
    <script>
    function goRandomSite(sites) {
    var target = Math.floor(Math.random()*sites.length);
    window.location = sites[target];
    }
    </script>
    to the page HTML code (head) and then would use a link like this
    Code:
    javascript:goRandomSite(["http://www.dilbert.com","http://stackoverflow.com","http://Starwars.com"]);
    Please note that in your example the multiplication character is missing.

  5. #15
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,916

    Default Re: Random link

    Thanks a lot for that Siran, that worked a treat.
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  6. #16
    Join Date
    Mar 2009
    Location
    Crestone, CO. USA
    Posts
    33

    Default Re: Random link

    I'd love to know how to do a random pop-up layer, working on a dice roll animation that also goes to a web-page correlated to the number rolled
    press button, pop-up shows your roll then opens your web-page (36 pages possible)...

 

 

Bookmarks

Posting Permissions

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