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
    Regular Coder
    Join Date
    Oct 2010
    Posts
    127
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Changing this javascript to open up in new window

    Hey all, I have a rotating banner that I'm having to embedd with an iframe on a webpage. I'm trying to get the links to open up in a new window. However, the target_blank isn't working. How do I adjust the js to do so? Thanks

    Code:
    <HTML><HEAD>
    <TITLE>Rotating Banners</TITLE>
    <meta name="robots" content="noindex">
    <style type="text/css">
    <!--
    body {
    margin: 0px;
    }
    -->
    </style>
    
    <script type="text/javascript">
    <!-- Beginning of JavaScript -
    
    if (document.images) {
    ads = new Array(5);
    ads[0] = "/arts/rotatorpics/banners/ac.jpeg";
    ads[1] = "/rotatorpics/banners/dustbowl.jpeg";
    ads[2] = "/rotatorpics/banners/KACVFM_AudioStream.gif";
    ads[3] = "/rotatorpics/banners/ranger.jpeg";
    ads[4] = "/rotatorpics/banners/kacv.jpeg";
    }
    
    newplace = new Array(5);
    newplace[0] = "/register"
    newplace[1] = "http://www.daysofdust.org"
    newplace[2] = "/toyota"
    newplace[3] = "/ranger"
    newplace[4] = "/acl"
    
    var timer = null
    var	 counter = 0
    
    function banner() {
    	    timer=setTimeout("banner()", 120000);
    		counter++;
    		if (counter >= 5)
    		counter = 0;
    		document.bannerad.src = ads[counter];
    }
    
    function gothere() {
    		counter2 = counter;
    		window.location.href = newplace[counter2];
    }
    
    // - End of JavaScript - -->
    </SCRIPT>
    
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" onload="banner()">
    
    <a href="javascript:gothere()" target="_blank"><IMG SRC="http://kacv.org/arts/rotatorpics/banners/ac.jpeg" WIDTH="728" HEIGHT="90" BORDER="0" NAME="bannerad"></a>
    
    </BODY>
    </HTML>

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    target has been deprecated. Write the function so that it will use window.open.

    Also, I recommend not using "javascript:function()" in the href. Make the href "javascript:void(0);" and call the function with onclick.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • Users who have thanked WolfShade for this post:

    javanewbie7 (11-02-2012)

  • #3
    Regular Coder
    Join Date
    Oct 2010
    Posts
    127
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    target has been deprecated. Write the function so that it will use window.open.

    Also, I recommend not using "javascript:function()" in the href. Make the href "javascript:void(0);" and call the function with onclick.
    Thank you. I will make the changes.


  •  

    Posting Permissions

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