...

View Full Version : Changing this javascript to open up in new window



javanewbie7
11-02-2012, 04:38 PM
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



<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>

WolfShade
11-02-2012, 04:46 PM
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.

javanewbie7
11-02-2012, 04:51 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum