Forum Moderators: open

Message Too Old, No Replies

new window

please read

         

masterjr

3:34 am on Jan 5, 2002 (gmt 0)

10+ Year Member



hello.
please i your are nice take the time to read this request.I'm using a javascript to show advertising and i want that when i user click the link open in a new window.please tell me how to do.
thsi is the code:
<html>

<head>

<script language="JavaScript">
<!-- Begin
pubs=new Array();
liens=new Array();
pubT=0;
pub = -1;
function AfficherPub(pubs,pubDelay1) {
pubDelay = pubDelay1;

pub = pub + 1;
if (pub == pubs.length)
pub = 0;
document.pubImg.src = pubs[pub];
pubT = setTimeout("AfficherPub(pubs,pubDelay)", pubDelay1);
}
// End -->
</script>
<script language="JavaScript">
<!-- Begin
function VersionNavigateur(Netscape, Explorer) {
if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ¦¦
(navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
return true;
else return false;
}
// End -->
</script>

</head>
<body onUnload="clearTimeout(pubT)">

<a href="" onClick="location=liens[pub]; return false">
<img name="pubImg" src="image0" width="20" height="20" border="0"></a>

<script language="JavaScript">
<!-- Begin
if (VersionNavigateur(3.0,4.0))
{
pubs[0] = document.pubImg.src;
liens[0]='url0';
pubs[1]="image1"
liens[1]="url1"

pubs[2]="image2"
liens[2]="url2"

AfficherPub(pubs,10000);
}

// End -->
</script>

</body>
</html>
thank you.

netcommr

5:49 am on Jan 5, 2002 (gmt 0)

10+ Year Member



<a href="" onClick="location=liens[pub]; return false" target="_blank">

tedster

6:48 am on Jan 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think the target="_blank" will open a new window in this case -- javascript will load the new location in the existing window, but return false to the target="_blank" section of the anchor tag.

If I'm right and you don't get a new window with netcommr's code, try this:

<a href="" onClick="window.open(liens[pub]); return false">

Also, if you are using this for advertising, you'll probably want to control the features of the new window (especially the size). Here's a reference [webreference.com].

masterjr

2:48 am on Jan 6, 2002 (gmt 0)

10+ Year Member



thank you.

steveuk

2:50 pm on Jan 10, 2002 (gmt 0)

10+ Year Member



For your info, if you want to avoid having to try and code all this yourself, there's various free JavaScript popup window code generators available on the web, such as the one at url snipped see profile - this one comes with easy instructions so all you do is just copy the code and paste it into your web page.

Hope this helps
Steve

(edited by: engine at 5:29 pm (utc) on Jan. 10, 2002)