Forum Moderators: open
Now that’s what I want it to do. It does it all except opening the link on the index.html page. Now the code that I am using is …….
This is the code on the index.html page
<script language="JavaScript" type="text/javascript">
<!---
this.name="parentWindow";
// --->
</script>
And the is the code on the pop-window page
<script language="JavaScript">
<!--
function linkClose(obj) {
self.opener.location.href = obj;
this.close();
return false;
}
/////////////////////////
// Date variables and leap year function
/////////////////////////
var currDate = new Date();
var currMonth = currDate.getMonth() + 1;
var currDay = currDate.getDate();
var currHour = currDate.getHours();adImages = new Array("Images/BellGuatemala/antiguaR.jpg","Images/BellBrazil/sugarR.jpg","Image/BellBelize/cavernasR.jpg","Images/BellArgentina/ischigualastoR.jpg","Images/BellCostaRica/arenalR.jpg","Images/BellPeru/machupicR.jpg")
adAlt = new Array("The Land of Eternal Spring","The Country of Different Sights and Sounds","The Country of Natural Wonders","The Land of the six Continents","The Central American Switzerland","The Legacy Of The Incas")
adURL = new Array("page1.html","page2.html","page3.html","page4.html","page5.html","page6.html")
if ((currHour == 1) ¦¦ (currHour == 5) ¦¦ (currHour == 9) ¦¦ (currHour == 13) ¦¦ (currHour == 17) ¦¦ (currHour == 21)) {
thisAd = 0
} else if ((currHour == 2) ¦¦ (currHour == 6) ¦¦ (currHour == 10) ¦¦ (currHour == 14) ¦¦ (currHour == 18) ¦¦ (currHour == 22)) {
thisAd = 1
} else if ((currHour == 3) ¦¦ (currHour == 7) ¦¦ (currHour == 11) ¦¦ (currHour == 15) ¦¦ (currHour == 19) ¦¦ (currHour == 23)) {
thisAd = 2
} else {
thisAd = 3
}
imgCt = adImages.length
function rotate() {
if (document.images) {
if (document.picture.complete) {
thisAd++
if (thisAd == imgCt) {
thisAd = 0
}
document.picture.src=adImages[thisAd]
}
setTimeout("rotate()", 4 * 1000)
}
}
function newLocation() {
document.location.href = adURL[thisAd]
}
// -->
</script>
<script language="JavaScript" src="popup.js"></script>
<SCRIPT TYPE="text/javascript">
<!--
if (!ns6) {
window.focus();
}
//-->
</SCRIPT>
<body onLoad="rotate()" bgcolor="#FF9c39">
<center>
<a target="parentWindow" href="java script:newLocation();" onClick="linkClose(this.href);"><img name="picture" src="Images/main-startingpic.gif" width="119" height="92" alt="Travel" border="0"></a>
</center>
</body>
Thanks for any help given
(edited by: tedster at 7:42 am (gmt) on Dec. 24, 2001)
<a href="newdocument.html" onClick="window.opener.location='newdocument.html';window.close();return false">Click Here</a>
No need to give a name to the original window, and no need to use "target=".
Can you adapt that concept to your code?
href="JavaScript:*newLocation();"
*The bold javascript is the problem
that is giving me trouble.
The problem is that I need to use the function newLocation() because it gives me a dinamic page sort of speaking. It draws from the array variable
adURL that is close to the top
But thanks for the help :)
All you have to do is put the code tedster gave you in the onclick event into your newLocation() function... Everything should work after that. Assuming that the astericks isn't actually part of your code, of course :-)
Also, I'd recommend putting the function call into the onclick event instead of the href property (drop the javascript: as that's only needed in href) and then add ;return false (as ted suggested) that way you can put an alternate url for search engines into the href property.