Forum Moderators: open

Message Too Old, No Replies

<a target="parentWindow" href=" -----

         

circuitjump

6:41 am on Dec 24, 2001 (gmt 0)

10+ Year Member



Hi all,
I have a small problem. I am making a page with a pop-window that shows random pictures. The pictures rotate every few seconds. You can click on whichever picture is there at present. When you click on it, the pop-up window closes and the link opens on the main page. ( Meaning the index.html page )

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)

tedster

7:51 am on Dec 24, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Close the pop-up and load a new document in original window? I get that functionality by using this code in the pop-up page:

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

IanKelley

8:56 am on Dec 24, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Looks like someone needs to update the wrapping code on this board :-)

Just one thing to add... If you're going to rely on a link opening in the parent window I'd suggest writing some code to reopen the parent if it has been closed.

circuitjump

8:58 am on Dec 24, 2001 (gmt 0)

10+ Year Member



Hi tedster,
It works but I have figured out that it is the

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

IanKelley

10:35 pm on Dec 24, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hmmm... I take it that means you don't know Javascript?

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.

circuitjump

2:54 am on Dec 25, 2001 (gmt 0)

10+ Year Member



Not much,
I'm more of the PHP and ASP type of guy. :)
But JavaScript makes sense, just need a little help here and there.

Thanks, I'll try it out

circuitjump

3:01 am on Dec 25, 2001 (gmt 0)

10+ Year Member



HAHA!!!

It worked.
I put the code in
newLocation() like so

function newLocation() {
window.opener.location = document.location.href = adURL[thisAd];
window.close();
return false
}

and I changed the anchor tag to

<a href="javascript:newLocation();">Click Here</a>

Thank You all for the HELP :)