Previous Thread
Next Thread
Print Thread
Hop To
Joined: Oct 2006
Posts: 49
W
journeyman
journeyman
W Offline
Joined: Oct 2006
Posts: 49
All,

I added some javascript code to my default header and can't make it work. Then I moved the javascript to the header insert area and it works fine. The problem with the javascript in the header insert area, I now can't have unique headers in forums that I have the unique header/footer button checked as the javascript and banners are added to EVERY forum on top of the unique banners.

How can I make the javascript work for the default forum page and have individual headers for other forums?

Thanks,

Wayne

Joined: Apr 2007
Posts: 3,940
Likes: 1
SD Offline
Former Developer
Former Developer
Joined: Apr 2007
Posts: 3,940
Likes: 1
you should be able to insert javascript anywhere (within reason).. i have it in the footer.tpl sometimes..

might just be the syntax you are using..

would help to see what you are inserting to give more aid smile

Joined: Oct 2006
Posts: 49
W
journeyman
journeyman
W Offline
Joined: Oct 2006
Posts: 49
Below is the actual code:

Code
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Bob Is The Oil Guy</title>

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
  <!--
  //JavaScript Rotating Banners
  //copyright daxassist, 2000-2004
  //visit http://www.daxassist.com for this and other javascripts with full tutorials.

  //specify interval between rotating banners (in mili seconds)
  var currentlink = 0;
  var currentimage = 0;
  var delay = 20000;
  var newbrowser = true;
	
  //specify banners
  if(document.images) {
    banpics = new Array();	
    banpics[0] = new Image();
    banpics[0].src = "http://www.bobistheoilguy.com/images/blackstone728x90.jpg";
    banpics[1] = new Image();
    banpics[1].src = "http://www.bobistheoilguy.com/images/schaeffers/gif-anim-headlines72.gif";

		
    //specify banner links
    banlinks = new Array();	
    banlinks[0] = "http://www.blackstone-labs.com/free_test_kit.html";
    banlinks[1] = "http://www.schaefferoil.com/";

    		
  }		
			
  function bannerchanger(from) {
    if(document.images) {
      document.images[from].src = banpics[currentimage].src;
      currentlink = currentimage;			
      if (currentimage < banpics.length-1) 
        currentimage = currentimage + 1;
      else 
        currentimage = 0;
      setTimeout("bannerchanger('" + from + "')", delay);
    }
  }
	
  function FollowLink() {
    if(document.images) {
      if (newbrowser == true) {
        window.open(banlinks[currentlink], 'newwindow', '', false);			
      } else
        document.location.href = banlinks[currentlink];
    }
  }
	
  //-->
</script>


</head>

<p align="center"><a href="http://www.bobistheoilguy.com"><img border="0" src="http://www.bobistheoilguy.com/banner.gif" width="760" height="150"></a>

<body onload="bannerchanger('banner');">

<p align="center">

<a href="javascript:FollowLink();"><img id="banner" name="banner"  src="http://www.bobistheoilguy.com/images/blackstone728x90.jpg" border=0></a>

</body>

</html>

Joined: Aug 2006
Posts: 1,649
Likes: 1
Pooh-Bah
Pooh-Bah
Joined: Aug 2006
Posts: 1,649
Likes: 1

You're not including the HTML tags, are you? Those may be conflicting with the current HTML/HEAD/BODY tags...


GangsterBB.NET (Ver. 7.6.1.1)
PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54
2007 Content Rulez Contest - Hon Mention
UBB.classic 6.7.2 - RIP
Joined: Oct 2006
Posts: 49
W
journeyman
journeyman
W Offline
Joined: Oct 2006
Posts: 49
Originally Posted by jgeoff
You're not including the HTML tags, are you? Those may be conflicting with the current HTML/HEAD/BODY tags...

I've taken them out and the code is posted below - still doesn't work.

Code
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
  <!--
  //JavaScript Rotating Banners
  //copyright daxassist, 2000-2004
  //visit http://www.daxassist.com for this and other javascripts with full tutorials.

  //specify interval between rotating banners (in mili seconds)
  var currentlink = 0;
  var currentimage = 0;
  var delay = 20000;
  var newbrowser = true;
	
  //specify banners
  if(document.images) {
    banpics = new Array();	
    banpics[0] = new Image();
    banpics[0].src = "http://www.bobistheoilguy.com/images/blackstone728x90.jpg";
    banpics[1] = new Image();
    banpics[1].src = "http://www.bobistheoilguy.com/images/schaeffers/gif-anim-headlines72.gif";

		
    //specify banner links
    banlinks = new Array();	
    banlinks[0] = "http://www.blackstone-labs.com/free_test_kit.html";
    banlinks[1] = "http://www.schaefferoil.com/";

    		
  }		
			
  function bannerchanger(from) {
    if(document.images) {
      document.images[from].src = banpics[currentimage].src;
      currentlink = currentimage;			
      if (currentimage < banpics.length-1) 
        currentimage = currentimage + 1;
      else 
        currentimage = 0;
      setTimeout("bannerchanger('" + from + "')", delay);
    }
  }
	
  function FollowLink() {
    if(document.images) {
      if (newbrowser == true) {
        window.open(banlinks[currentlink], 'newwindow', '', false);			
      } else
        document.location.href = banlinks[currentlink];
    }
  }
	
  //-->
</script>


<p align="center"><a href="http://www.bobistheoilguy.com"><img border="0" src="http://www.bobistheoilguy.com/banner.gif" width="760" height="150"></a>

<body onload="bannerchanger('banner');">

<p align="center">

<a href="javascript:FollowLink();"><img id="banner" name="banner"  src="http://www.bobistheoilguy.com/images/blackstone728x90.jpg" border=0></a>

Joined: Aug 2006
Posts: 1,649
Likes: 1
Pooh-Bah
Pooh-Bah
Joined: Aug 2006
Posts: 1,649
Likes: 1

The <body onload=""> would need to be added to:
Control Panel » Display Options » HTML Includes » Body Onload as such:
HTML
bannerchanger('banner');

Do you just want the banner to appear at the top of every page? That's what I have (check my site), and I have my code in the Default Header section like below. This is basically a table that on the left has my site logo, and on the right I have banners rotating on every page of the forums.
HTML
<BR />

<TABLE align="center" width="800">
<TR>
<TD align="center" valign="middle" width="325">
<a href="http://www.gangsterbb.net/threads/ubbthreads.php?ubb=cfrm" target="_top">
<IMG width="300" height="50" src="images/title_gangster-bb.gif" 
border="0" alt="GangsterBB.NET" align="left"></a>
</TD>
<TD align="center" valign="middle">

<!-- BANNER ROTATION -->

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
var border = 0;
ad +=1;


if (ad==1) {
txt="Search over 400,000 posters, photos, t-shirts, gifts, and more!"; 
url="http://www.MobPosters.com/";
alt="MobPosters";
banner="http://www.MobPosters.com/img/468x60-anim.gif";
width="468";
height="60";
}

if (ad==2) {
txt="2008 CALENDARS: Search for Scarface (GF sold out!)"; 
url="http://www.anrdoezrs.net/click-2207240-10481683";
alt="2008 Calendars";
banner="http://www.awltovhc.com/image-2207240-10481683";
width="468";
height="60";
border="0";
}

if (ad==3) {
txt="TEXT THAT SHOWS UNDERNEATH THE AD"; 
url="THE URL PEOPLE ARE SENT TO";
alt="SHORT TEXT IF IMAGE ISN'T LOADED";
banner="LOCATION/OF/THE/BANNER.GIF";
width="468";
height="60";
border="0";
}


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

</SCRIPT>
</TD></TR></TABLE>
<BR />


If that's all you need, you can just modify the code I use to include however many banners you want to rotate by changing this: var how_many_ads = 3;

You wouldn't need the Body Onload section using this.

If you want the ads somewhere else, then there'd be a different procedure....




GangsterBB.NET (Ver. 7.6.1.1)
PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54
2007 Content Rulez Contest - Hon Mention
UBB.classic 6.7.2 - RIP
Joined: Aug 2006
Posts: 1,649
Likes: 1
Pooh-Bah
Pooh-Bah
Joined: Aug 2006
Posts: 1,649
Likes: 1
Originally Posted by Wayne Willson
How can I make the javascript work for the default forum page and have individual headers for other forums?

Okay, I just noticed this. wink

You may have to settle for including specific banners in the "Forum Intro" section of each forum at Control Panel » Forum Settings » [FORUM NAME/Details] » Forum Introduction Body. That would, however, only include the banner on the forum's postlist page and not every page...

Maybe someone else has a better idea.


GangsterBB.NET (Ver. 7.6.1.1)
PHP Version 5.6.40 / MySQL 5.7.23-23 (was 5.6.41-84.1) / Apache 2.4.54
2007 Content Rulez Contest - Hon Mention
UBB.classic 6.7.2 - RIP
Joined: Oct 2006
Posts: 49
W
journeyman
journeyman
W Offline
Joined: Oct 2006
Posts: 49
bannerchanger('banner');

In the 'Body Onload'

This was the key!!!!

Thanks a million,

Wayne


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Bots
by Outdoorking - 04/13/2024 5:08 PM
Can you add html to language files?
by Baldeagle - 04/07/2024 2:41 PM
Do I need to rebuild my database?
by Baldeagle - 04/07/2024 2:58 AM
This is not a bug, but a suggestion
by Baldeagle - 04/05/2024 11:25 PM
Is UBB.threads still going?
by Aaron101 - 04/01/2022 8:18 AM
Who's Online Now
2 members (Napalm, 1 invisible), 867 guests, and 189 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20230217)