Target=... help me

Status
Niet open voor verdere reacties.

Smartguy

Meubilair
Lid geworden
13 jul 2001
Berichten
7.240
Hoi,

ik heb een probleem. Op mijn site heb ik een bannerscript gezet. Maar nu krijg ik het niet voor elkaar om de links verbonden met de banners in een nieuw venster te openen. Het blijft openen in het frame waar de banners staan.

PHP:
<script type="text/javascript">

if (document.images)
{
    // First create an array with links to the images you want to
    // display as banners. I chose 3 image locations.
    adImages = new Array("http://www.puzzelland.com/iconen/buttonpuzzelland2002.jpg",
                         "http://www.dutchleader.nl/banner468x60.gif");                                                   
                         
    // When the user clicks on a banner it should take the user to
    // the website of that company. Therefore we create another
    // array with a list of URLs. Keep the order the same as images.
    adURLs = new Array ("www.puzzelland.com",
                       "www.dutchleader.com/php/ref.php?id=Smartguy");
    thisAd = 0;
}

// The following function cycles through each banner image.
// Notice the use of the variable thisAd to go from 0 to 2 and then
// back to 0. JavaScript has an object called document whose
// member adBanner can be set to the current banner to display.

function cycleAds()
{
    if (document.images)
    {
        if (document.adBanner.complete)
        {
            if (++thisAd == adImages.length)
                thisAd = 0;

            document.adBanner.src = adImages[thisAd];
        }
    }

    // change to next banner every 15 seconds
    setTimeout("cycleAds()", 4300);
}

// This function is used to direct the user to the website when
// the user clicks on a particular banner image.

function gotoAd()
{
    document.location.href = "http://" + adURLs[thisAd];
}
</script>
<a href="javascr!pt:gotoAd()><img name="adBanner" src="http://www.puzzelland.com/iconen/buttonpuzzelland2002.jpg" border="0" alt="banners"></a>

Ik heb de target code geprobeert achter <a href="javascr!pt:gotoAd(), maar als je dan op een banner klikt komt er in de Adresbalk alleen javascr!pt:gotoAd() te staan en geen site laad.

Van javascript heb ik hier even javascr!pt van gemaakt i.v.m de notallowed toestand.
 
doe eens een window.open ipv document.location.href

t.
 
Geplaatst door teacher
doe eens een window.open ipv document.location.href

t.
PHP:
function gotoAd()
{
    window.open = "http://" + adURLs[thisAd];
}

Zo dus? Of bij nog meer?

Maar dit werkt niet, dan opent hij niks
 
laat me raden, je hebt geen flauw idee hoe javascript werkt? ;)

Code:
    win=window.open("http://" + adURLs[thisAd]);

t.
 
Geplaatst door teacher
laat me raden, je hebt geen flauw idee hoe javascript werkt? ;)

Code:
    win=window.open("http://" + adURLs[thisAd]);

t.

Inderdaad :o.
Maar begin het al aardig te leren :cool:

Thanx! :)
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan