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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making a popup window show different .jpg files

    I want to have a dozen links on my web page
    such that clicking each link will pop up a different jpg file in a small window.

    I found the code below to create a popup window.

    Clicking link "Kevin" should pop up file kevinw.jpg (actually, that works)

    Clicking link "Flower" should pop up file
    photo19.jpg (that doesn't)

    How do I move the variable "popurl" out of the
    function so that I can assign it different
    values in different places on the web page?

    (Obviously variables in java don't work
    like variables in BASIC.)

    ===========================

    function openpopup(){
    var popurl="kevinw.jpg"
    winpops=window.open(popurl,"","width=400,height=338,")
    }

    </script>

    <a href="javascriptpenpopup()">Kevin</a>

    var popurl="photo19.jpg"
    <a href="javascriptpenpopup()">Flower</a>

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am not sure what you are trying to do but here is something I found on this forum a while back. I altered the code a bit to my need. It is quite simple to understand.

    Code:
    <head>
    	<script type="text/javascript">
    		if (document.images)
    		{
    			adImages = new Array("./Dru01.jpg", "./Dru02.jpg", "./Dru03.jpg", "./Dru04.jpg", "./Dru05.jpg");
    			adURLs = new Array("www.yahoo.com", "www.geocities.com", "www.yahoo.com", "www.yahoo.com", "www.yahoo.com");
    			int_Counter = 0;
    		}
    
    		function f_cycleAds()
    		{
    			if (document.images)
    			{
    				if (document.imgBox.complete)
    				{
    					if (++int_Counter == adImages.length)
    					{
    						int_Counter = 0;
    					}
    
    					document.imgBox.src = adImages[int_Counter];
    					window.status=int_Counter + '     ' + adImages[int_Counter] + '     ' + adURLs[int_Counter];
    				}
    			}
    
    			// change picture every 2 seconds
    			setTimeout("f_cycleAds()", 2000);
    		}
    
    		function f_Goto()
    		{
    			document.location.href = "http://" + adURLs[int_Counter];
    		}
    	</script>
    </head>
    <body onload="f_cycleAds()" text="blue">
    	<a href="javascript:f_Goto()">
    		<img name="imgBox" src="./Dru01.jpg" border="0" alt="Our sponsors">
    	</a>
    </body>

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    New York, USA
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script>
    function openpopup(popurl){
    winpops=window.open(popurl,"","width=400,height=338,")
    }
    </script>
    <a href="javascript:openpopup('kevinw.jpg')">Kevin</a>
    <a href="javascript:openpopup('photo19.jpg')">Flower</a>


  •  

    Posting Permissions

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