Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    opening links from random image script in resized window???

    I have been trying to get this script to let me open the linked page in a new window that I can resize with no toolbars or scrollbars. This is the code I have, any help would be appreciated...

    Code:
    <script language="JavaScript">
    <!--
    /*
    Random Image Link Script
    By Website Abstraction (http://www.wsabstract.com)
    and Java-scripts.net (http://www.java-scripts.net)
    */
    
    function random_imglink(){
      var myimages=new Array()
      //specify random images below. You can have as many as you wish
      myimages[1]="splash/patboy.jpg"
      myimages[2]="splash/kevinboy.jpg"
      myimages[3]="splash/keithboy.jpg"
      myimages[4]="splash/chrisboy.jpg"
      myimages[5]="splash/danboy.jpg"
    
      //specify corresponding links below
      var imagelinks=new Array()
      imagelinks[1]="index2.html"
      imagelinks[2]="index2.html"
      imagelinks[3]="index2.html"
      imagelinks[4]="index2.html"
      imagelinks[5]="index2.html"
    
      var ry=Math.floor(Math.random()*myimages.length)
    
      if (ry==0)
         ry=1
         document.write('<a href='+'"'+imagelinks[ry]+'"'+' target="_blank"><img src="'+myimages[ry]+'" border=0></a>')
    }
    
      random_imglink()
    //-->
    </script>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    You could combine the random image with

    http://www.vicsjavascripts.org.uk/Po...pGenerator.htm


    say if you need more help

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    more help would be excellent. my problem is that I can get it to open in a new window (by using HTML to target it to _blank). The problem is you can't define the parameters of the new window in HTML, and I dont know how to work the javascript open window code into the random image script. So, what I need is someone who could help me throw a java open window script into the random image code. Thank you guys in advance.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Code:
    ...
    document.write('<a href='+'"'+imagelinks[ry]+'"'+' target="mypopup" onclick="return doOpen(this.href, this.target, 600, 500)"><img src="'+myimages[ry]+'" border=0></a>');
    ...
    
    function doOpen(url, target, w, h){
      var w = window.open(url, target, "width="+w+", height="+h+", resizable=1, location=0, scrollbars=0");
      w.focus();
      return false;
    }

  • #5
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you so very much, works like a charm


  •  

    Posting Permissions

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