Click to See Complete Forum and Search --> : How do I open a new window


ReeKo
11-05-2004, 08:52 AM
First off I want to say that I have very to NO knowldege of java. I"m pretty stupid with it actually...:o The sript I have below is what i"m using in a VBB forum. I'm trying to make it so that when users click on the Logo in the forums it opens a new window. I do know that in HTML the --- target="_blank" --- in the <hREF> line is what makes a new window appear if someone clicks on a hyperlink. IS it possible to add this -- target="_blank" -- line somewere below to make the hyperlink open a new window. And Please forgive me if I"m not making sense all this is new to me.. Thank you for your time.

Here is a link http://www.quadzoneforums.com/forums/ to the site with the animated Gif/logos at the top that I want to open a new window if someone clicks on them.


<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="";
url="http://www.quadzn.com";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/chromenew.gif";
width="280";
height="64";
}
if (ad==2) {
txt="";
url="http://www.quadshopatv.com/";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/quadshopbanner.gif";
width="350";
height="45";
}
if (ad==3) {
txt="";
url="http://www.spidergrips.com/";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/spider_top.gif";
width="480";
height="90";
}
if (ad==4) {
txt="";
url="http://www.shok-spotr.com/";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/shokspotr_top.gif";
width="350";
height="100";
}


document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->

Khalid Ali
11-05-2004, 09:40 AM
You have posted your question in the wrong forum.
Your question is JavaScript related where as you have posted it in the Java forum. Which are 2 completely separate things.
Java is a complete (compiled) programing language which can be used to create from stand alone desktop applications to complete n-tier enterprise solutions.
JavaScript is an iterpreted scripting language that can only be used from within a HTTP GUI client(known as a web browser).
Please make a habbit of reading the stickies at the top of the forum. They are there for a purpose.
moving this thread to JavaScript forums.

ReeKo
11-05-2004, 09:51 AM
:eek:

Good Lord, excuse me. As stated i"m not familear with it. Sorry to ruin your day and get you all bent out of shape.

HaganeNoKokoro
11-05-2004, 10:03 AM
Well, everyone likes to keep the forums organized correctly, but we'll let you off with a warning. Next time, you get the chair ;)

Anyway, to open a window, you use the window.open function<script type="text/javascript">
var myWindow = window.open("http://www.google.ca", "_blank", "");
</script>

The third parameter is for you to tell it things like width, height, whether or not to have scrollbars, etc. You can find info on window.open here (http://www.w3schools.com/htmldom/dom_obj_window.asp)

ReeKo
11-05-2004, 11:22 AM
Thank you very much....:D

but were would I put that line in the script I posted above?? Remember I'm stoopid...:o

senshi
11-05-2004, 02:21 PM
A few changes.


<script language="JavaScript" type="text/javascript">
<!-- Begin
var sec =new Date().getSeconds()
var ad = sec % 4;
var txt="";
var banner="http://www.quadzoneforums.com/forums/images/Header_logos/"+["chromenew.gif","quadshopbanner.gif","spider_top.gif","shokspotr_top.gif"][ad];
var url=["http://www.quadzn.com","http://www.quadshopatv.com/","http://www.spidergrips.com/","http://www.shok-spotr.com/"][ad];
var altT=["atl text 1","atl text 2","atl text 3","atl text 4"][ad];
txt=altT
switch(ad){
case 0: var width="280", height="64";
break;
case 1: var width="350", height="45";
break;
case 2: var width="480", height="90";
break;
case 3: var width="350", height="100";
break;
} // end of switch
var x=window.open('','','');
x.document.write("<center><a href=\"" + url + "\" target=\"_top\"><img src=\"" + banner + "\" width=\""+width + "\" height=\"" + height + "\" alt=\"" + altT + "\" border=\"0\"><br><small>\"" + txt + "\"</small></a></center>");
// End -->
</script>


If you want your pop up to size to the banners or slightly larger to accomodate the Click URL, you will have to code that into the window.open string., eg.

var tmp="width="+width+",height="+height;
var x=window.open('','',tmp);

which will cause a sizes popup window.

Something to play with...

WebNut
02-08-2008, 02:33 PM
Below I include the modification to open a new window when you click in the ad:

<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="";
url="http://www.quadzn.com";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/chromenew.gif";
width="280";
height="64";
}
if (ad==2) {
txt="";
url="http://www.quadshopatv.com/";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/quadshopbanner.gif";
width="350";
height="45";
}
if (ad==3) {
txt="";
url="http://www.spidergrips.com/";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/spider_top.gif";
width="480";
height="90";
}
if (ad==4) {
txt="";
url="http://www.shok-spotr.com/";
alt="";
banner="http://www.quadzoneforums.com/forums/images/Header_logos/shokspotr_top.gif";
width="350";
height="100";
}


document.write('<center>');
//document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' onClick = window.open(\"'+ url + '\") height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->

Thanks

WebNut