/    Sign up×
Community /Pin to ProfileBookmark

JAvascript issue?

I’ve figured out how this page works, as far as setting everything up. A little copying of source code from gatewaypeople.com…i found that I learn it that way, then tweak it a bit…
Okay enough of that…I’m having issues with variables…probably somehting I copied. Don’t know how to fix..maybe this is a javascript related, i’m not sure, well here is my code:

[code=php]<head>
<script>
<!–

if (window.name!=”reloaded”) doRefresh();

function doRefresh(){
window.name=”reloaded”;
location.reload();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

var artCrossFadeDuration = 1; //seconds
var articleInterval = (2 * adInterval); //seconds
var numArticles = 4;
var curArticleIndex = 1;
var artMainPicArray = new Array(numArticles);
var artThumbPicArray = new Array(numArticles);
var artThumbArray = new Array(numArticles);
var artMainArray = new Array(numArticles);
var artUrls = new Array(numArticles);
var artTitles = new Array(numArticles);
var artShortDesc = new Array(numArticles);

artThumbArray[0] = “images/articles/thumbnail_cantata.jpg”;

artThumbArray[1] = “images/articles/thumbnail_camp.jpg”;

artThumbArray[2] = “images/articles/thumbnail_bio.jpg”;

artThumbArray[3] = “images/articles/thumbnail_crazy.jpg”;

artMainArray[0] = “images/articles/cantata.jpg”;

artMainArray[1] = “images/articles/camp.jpg”;

artMainArray[2] = “images/articles/bio.jpg”;

artMainArray[3] = “images/articles/crazy.jpg”;

artUrls[0] = “./cantata2007.html”;

artUrls[1] = “./summer_camp.html”;

artUrls[2] = “./bio.html”;

artUrls[3] = “./crazy.html”;

artTitles[0] = “Christmas Cantata 2007”;

artTitles[1] = “Summer Camp 2008”;

artTitles[2] = “BIO Fusion Group”;

artTitles[3] = “Home Friendship Groups Series”;

artShortDesc[0] = “Calvary Church Choir presents Come and Adore… “;

artShortDesc[1] = “Calvary’s Kids trip to Dry Gulch, USA Summer Camp 2008… “;

artShortDesc[2] = “Beauty Inside and Out (BIO)… “;

artShortDesc[3] = “Christian beliefs that can drive you crazy… “;

if(document.images) { //pre-load all article images
for(i = 0; i < numArticles; i++) {
artMainPicArray[i] = new Image(330, 165);
artMainPicArray[i].src = artMainArray[i];
artThumbPicArray[i] = new Image(66, 66);
artThumbPicArray[i].src = artThumbArray[i];
}
}
function changeArticle() { //article changer function
if(curArticleIndex > numArticles – 1) { curArticleIndex = 0; }
if(browser == “Microsoft Internet Explorer”) {
document.article0.style.filter=”blendTrans(duration=1)”;
document.article0.style.filter=”blendTrans(duration=artCrossFadeDuration)”;
document.article0.filters.blendTrans.Apply();

document.article1.style.filter=”blendTrans(duration=1)”;
document.article1.style.filter=”blendTrans(duration=artCrossFadeDuration)”;
document.article1.filters.blendTrans.Apply();

document.article2.style.filter=”blendTrans(duration=1)”;
document.article2.style.filter=”blendTrans(duration=artCrossFadeDuration)”;
document.article2.filters.blendTrans.Apply();

document.article3.style.filter=”blendTrans(duration=1)”;
document.article3.style.filter=”blendTrans(duration=artCrossFadeDuration)”;
document.article3.filters.blendTrans.Apply();
}
document.article0.src = artMainPicArray[((0 + curArticleIndex) % 4)].src; //sets a new article picture
document.article1.src = artThumbPicArray[((1 + curArticleIndex) % 4)].src; //sets a new article picture
document.article2.src = artThumbPicArray[((2 + curArticleIndex) % 4)].src; //sets a new article picture
document.article3.src = artThumbPicArray[((3 + curArticleIndex) % 4)].src; //sets a new article picture
if(browser == “Microsoft Internet Explorer”) {
document.article0.filters.blendTrans.Play();
document.article1.filters.blendTrans.Play();
document.article2.filters.blendTrans.Play();
document.article3.filters.blendTrans.Play();
}
// *** Main article ***
document.links.namedItem(‘article0_image’).href = artUrls[((0 + curArticleIndex) % 4)];

// *** 3 sub articles ***
for (var i = 1; i < 4; i++) {
document.links.namedItem(‘article’ + i + ‘_image’).href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem(‘article’ + i + ‘_title’).href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem(‘article’ + i + ‘_title’).innerHTML = artTitles[((i + curArticleIndex) % 4)];
document.links.namedItem(‘article’ + i + ‘_desc’).href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem(‘article’ + i + ‘_desc’).innerHTML = artShortDesc[((i + curArticleIndex) % 4)];
document.links.namedItem(‘article’ + i + ‘_moredetails’).href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem(‘map_mainarticle_more_area’).href = artUrls[curArticleIndex];
}
curArticleIndex++; //increase the counter for the next article
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//–>
</script>
[/code]

You can check out my source code: calvaryftw.com/sample.html

Any help would be appreciated!

to post a comment
JavaScript

15 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 05.2007 — I'm having issues with variables[/QUOTE]Be more specific.
Copy linkTweet thisAlerts:
@clydezjrauthorDec 06.2007 — when I upload to site...nothing happens.
Copy linkTweet thisAlerts:
@FangDec 06.2007 — You have 2 <head> elements and no DTD
Copy linkTweet thisAlerts:
@clydezjrauthorDec 06.2007 — do i need to remove one of them? and forgive my limited knowledge, but what is dtd and where do i need to place it?
Copy linkTweet thisAlerts:
@FangDec 06.2007 — A basic document will contain these elements:&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Basic HTML&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;

&lt;/script&gt;

&lt;style type="text/css"&gt;

&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
Compare the basic document to your document.

The first line is the DTD: http://www.w3.org/QA/Tips/Doctype
Copy linkTweet thisAlerts:
@clydezjrauthorDec 06.2007 — mine does not..do i simply put one in?
Copy linkTweet thisAlerts:
@FangDec 06.2007 — Yes, but it will change the layout slightly.
Copy linkTweet thisAlerts:
@clydezjrauthorDec 06.2007 — yea, i tried it and it jacked up the webpage...check it out calvaryftw.com/sample.html

even adding the dtd, it didn't fix the image swapping effect I was aiming for as in gatewaypeople.com

any advice?
Copy linkTweet thisAlerts:
@FangDec 06.2007 — The image swapping is not initialized.

Try:window.onload=changeArticle;

Use still have 2 <head> elements
Copy linkTweet thisAlerts:
@clydezjrauthorDec 06.2007 — where would I place that?
Copy linkTweet thisAlerts:
@FangDec 06.2007 — In the [I]script[/I] element
Copy linkTweet thisAlerts:
@clydezjrauthorDec 06.2007 — thanks...i'll give it a shot.
Copy linkTweet thisAlerts:
@clydezjrauthorDec 06.2007 — man...i'm going crazy...still no luck
Copy linkTweet thisAlerts:
@FangDec 07.2007 — The JavaScript references elements that doe not exist.&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;!-- InstanceBegin template="/Templates/Calvary Template.dwt" codeOutsideHTMLIsLocked="false" --&gt;
&lt;link rel="stylesheet" type="text/css" href="styles.css"&gt;
&lt;!-- InstanceBeginEditable name="doctitle" --&gt;
&lt;title&gt;Where The Journey Begins!&lt;/title&gt;
&lt;script&gt;
if (window.name!="reloaded") doRefresh();

function doRefresh(){
window.name="reloaded";
location.reload();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

var artCrossFadeDuration = 1; //seconds//seconds
var numArticles = 4;
var curArticleIndex = 1;
var artMainPicArray = new Array(numArticles);
var artThumbPicArray = new Array(numArticles);
var artThumbArray = new Array(numArticles);
var artMainArray = new Array(numArticles);
var artUrls = new Array(numArticles);
var artTitles = new Array(numArticles);
var artShortDesc = new Array(numArticles);

artThumbArray[0] = "images/articles/thumbnail_cantata.jpg";
artThumbArray[1] = "images/articles/thumbnail_camp.jpg";
artThumbArray[2] = "images/articles/thumbnail_bio.jpg";
artThumbArray[3] = "images/articles/thumbnail_crazy.jpg";

artMainArray[0] = "images/articles/cantata.jpg";
artMainArray[1] = "images/articles/camp.jpg";
artMainArray[2] = "images/articles/bio.jpg";
artMainArray[3] = "images/articles/crazy.jpg";

artUrls[0] = "./cantata2007.html";
artUrls[1] = "./summer_camp.html";
artUrls[2] = "./bio.html";
artUrls[3] = "./crazy.html";

artTitles[0] = "Christmas Cantata 2007";
artTitles[1] = "Summer Camp 2008";
artTitles[2] = "BIO Fusion Group";
artTitles[3] = "Home Friendship Groups Series";

artShortDesc[0] = "Calvary Church Choir presents Come and Adore... ";
artShortDesc[1] = "Calvary's Kids trip to Dry Gulch, USA Summer Camp 2008... ";
artShortDesc[2] = "Beauty Inside and Out (BIO)... ";
artShortDesc[3] = "Christian beliefs that can drive you crazy... ";

if(document.images) { //pre-load all article images
for(i = 0; i &lt; numArticles; i++) {
artMainPicArray[i] = new Image(330, 165);
artMainPicArray[i].src = artMainArray[i];
artThumbPicArray[i] = new Image(66, 66);
artThumbPicArray[i].src = artThumbArray[i];
}
}
function changeArticle() { //article changer function
var browser=navigator.appName;
if(curArticleIndex &gt; numArticles - 1) { curArticleIndex = 0; }
if(browser == "Microsoft Internet Explorer") {
document.article0.style.filter="blendTrans(duration=1)";
document.article0.style.filter="blendTrans(duration=artCrossFadeDuration)";
document.article0.filters.blendTrans.Apply();

<i> </i>document.article1.style.filter="blendTrans(duration=1)";
<i> </i>document.article1.style.filter="blendTrans(duration=artCrossFadeDuration)";
<i> </i>document.article1.filters.blendTrans.Apply();

<i> </i>document.article2.style.filter="blendTrans(duration=1)";
<i> </i>document.article2.style.filter="blendTrans(duration=artCrossFadeDuration)";
<i> </i>document.article2.filters.blendTrans.Apply();

<i> </i>document.article3.style.filter="blendTrans(duration=1)";
<i> </i>document.article3.style.filter="blendTrans(duration=artCrossFadeDuration)";
<i> </i>document.article3.filters.blendTrans.Apply();
}
document.article0.src = artMainPicArray[((0 + curArticleIndex) % 4)].src; //sets a new article picture
document.article1.src = artThumbPicArray[((1 + curArticleIndex) % 4)].src; //sets a new article picture
document.article2.src = artThumbPicArray[((2 + curArticleIndex) % 4)].src; //sets a new article picture
document.article3.src = artThumbPicArray[((3 + curArticleIndex) % 4)].src; //sets a new article picture
if(browser == "Microsoft Internet Explorer") {
document.article0.filters.blendTrans.Play();
document.article1.filters.blendTrans.Play();
document.article2.filters.blendTrans.Play();
document.article3.filters.blendTrans.Play();
}
// *** Main article ***
document.links.namedItem('article0_image').href = artUrls[((0 + curArticleIndex) % 4)];

// *** 3 sub articles ***
for (var i = 1; i &lt; 4; i++) {
document.links.namedItem('article' + i + '_image').href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem('article' + i + '_title').href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem('article' + i + '_title').innerHTML = artTitles[((i + curArticleIndex) % 4)];
document.links.namedItem('article' + i + '_desc').href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem('article' + i + '_desc').innerHTML = artShortDesc[((i + curArticleIndex) % 4)];
document.links.namedItem('article' + i + '_moredetails').href = artUrls[((i + curArticleIndex) % 4)];
document.links.namedItem('map_mainarticle_more_area').href = artUrls[curArticleIndex];
}
curArticleIndex++; //increase the counter for the next article
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&amp;&amp;i&lt;a.length&amp;&amp;(x=a[i])&amp;&amp;x.oSrc;i++) x.src=x.oSrc;
}

window.onload=changeArticle;
&lt;/script&gt;
&lt;!-- InstanceEndEditable --&gt;
&lt;!-- InstanceBeginEditable name="head" --&gt;
&lt;style type="text/css"&gt;
.style22 {
font-size: 9pt;
font-weight: bold;
}
.style24 {
font-size: 10pt;
color: #a55b2b;
}
&lt;/style&gt;
&lt;!-- InstanceEndEditable --&gt;
&lt;/head&gt;
&lt;body bgcolor="#ac7381" text="#000000" link="#000000" vlink="#000000" alink="#000000" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0"&gt;
Copy linkTweet thisAlerts:
@clydezjrauthorDec 07.2007 — that's what i get for copying source code...do you have any suggestions on getting the same result via a different method?
×

Success!

Help @clydezjr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...