vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=168)
-   -   Why does this code work there but not here? (https://vborg.vbsupport.ru/showthread.php?t=320107)

COOLORANGEFREEZ 09-03-2015 10:13 PM

Why does this code work there but not here?
 
So I'm using the exact same code for rotating banners on my regular html cover page site (http://www.wartornnations.net/) and for my vBulletin 3.8.3 too (http://www.wartornnations.net/forum/).

It rotates just fine on the html site but it rotates sporadically only when I refresh the vBulletin site. What in the vBulletin code would hang up such a simple banner rotation code?

Any help is appreciated. The code follows:

HTML SITE CODE:

Code:

<html>
<head>
<title>www.wartornnations.net</title>
</head>
<body>
<DIV ALIGN=CENTER>
<script language="JavaScript">
<!--
function adArray() {
 for (i=0; i*2<adArray.arguments.length; i++) {
  this[i] = new Object();
  this[i].src = adArray.arguments[i*2];
  this[i].href = adArray.arguments[i*2+1];
 }
 this.length = i;
}
function getAdNum() {
 dat = new Date();
 dat = (dat.getTime()+"").charAt(8);
 if (dat.length == 1)
  ad_num = dat%ads.length;
 else
  ad_num = 0;
 return ad_num;
}
 var ads = new adArray(
"http://d2ysc6lw6qcd4g.cloudfront.net/728x90-proudly-support.jpg",
"http://www.woundedwarriorproject.org/",
"http://www.veteranscrisisline.net/banners/public/ads/VeteransCrisisLine-728x90-1-Static.gif",
"http://www.veteranscrisisline.net/"
);

var ad_num = getAdNum();

document.write('<table cellpadding=0 cellspacing=1 border=0><tr><td '
+'align="left">'
+'<A href="'+ads[ad_num].href+'"><IMG SRC="'+ads[ad_num].src+'" '
+'height="60" width="468" border="0" name="js_ad"></a></td></tr></table>');

link_num = document.links.length-1;

function rotateBanner() {
 if (document.images) {
  ad_num = (ad_num+1)%ads.length;
  document.js_ad.src = ads[ad_num].src;
  document.links[link_num].href = ads[ad_num].href;
  setTimeout("rotateBanner()",5000);
 }
}
setTimeout("rotateBanner()",5000);

// -->
</script>
</DIV>
</body>
</html>

VBULLETIN HEADER CODE:

Code:

<html>
<head>
<title>UKBL ~ 10 Second Banner Rotator</title>
</head>
<body>
<DIV ALIGN=CENTER>
<script language="JavaScript">
<!--
function adArray() {
 for (i=0; i*2<adArray.arguments.length; i++) {
  this[i] = new Object();
  this[i].src = adArray.arguments[i*2];
  this[i].href = adArray.arguments[i*2+1];
 }
 this.length = i;
}
function getAdNum() {
 dat = new Date();
 dat = (dat.getTime()+"").charAt(8);
 if (dat.length == 1)
  ad_num = dat%ads.length;
 else
  ad_num = 0;
 return ad_num;
}
 var ads = new adArray(
"http://d2ysc6lw6qcd4g.cloudfront.net/728x90-proudly-support.jpg",
"http://www.woundedwarriorproject.org/",
"http://www.veteranscrisisline.net/banners/public/ads/VeteransCrisisLine-728x90-1-Static.gif",
"http://www.veteranscrisisline.net/",
"http://firstrespondersomaha.org/wp-content/uploads/2015/03/TrueBlue-728x90.gif",
"http://firstrespondersomaha.org/support-blue-materials/"
);

var ad_num = getAdNum();

document.write('<table cellpadding=0 cellspacing=1 border=0><tr><td '
+'align="left">'
+'<A href="'+ads[ad_num].href+'"><IMG SRC="'+ads[ad_num].src+'" '
+'height="90" width="728" border="0" name="js_ad"></a></td></tr></table>');

link_num = document.links.length-1;

function rotateBanner() {
 if (document.images) {
  ad_num = (ad_num+1)%ads.length;
  document.js_ad.src = ads[ad_num].src;
  document.links[link_num].href = ads[ad_num].href;
  setTimeout("rotateBanner()",5000);
 }
}
setTimeout("rotateBanner()",5000);

// -->
</script>
</DIV>
</body>
</html>


Lynne 09-03-2015 10:37 PM

You didn't add the <html> and <body> and <head> tags (and other tags that go with those) into the header, did you? You are going to break the html on your site if you don't just add the javascript for it into the header template.

COOLORANGEFREEZ 09-03-2015 10:46 PM

I did add those.

I will take them out and reassess later this eve.

Thanks for the quick response.

Lynne 09-04-2015 10:43 PM

After you change it, run the page through here and see if there are any errors related to any of the code you added - http://validator.w3.org/

COOLORANGEFREEZ 09-25-2015 07:38 PM

Way overdue... thank you for your suggestion. It worked.


All times are GMT. The time now is 11:35 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01737 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete