Solved

javascript code error

Posted on 2010-09-19
11
566 Views
Last Modified: 2012-05-10
I think I have looked at this took long because I cannot find my error - I believe the error is in the 1st js file - When I try to open htm file I see formatting etc but I do not see the 1-10 items
Could someone please take a look - any help or direction is appreciated.
 experts-exch-question.docx
0
Comment
Question by:NannaG
  • 5
  • 4
  • 2
11 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33712717
First js file.
You have 2 cases where normal"  had no starting double-quote.
1 case where rgb...)" has an extra double quote at the end.
1 case where "rgb...)" has double quotes at the beginning and end.
function eventSource(e) {

   var IE=document.attachEvent ? true:false;

   var DOM=document.addEventListener ? true: false;

   if (IE) return event.srcElement;

   else if (DOM) return e.currentTarget;

}



function setUpTranslation() { 

var phrases=document.getElementsByTagName ("p");

for (var i=0; i < phrases.length; i++) {

phrases[i].number = i; 

phrases[i].childNodes[1].innerHTML = french[i];

phrases[i].childNodes[1].style.fontStyle = "italic";

phrases[i].childNodes[1].style.color = "#000";



phrases[i].onmousedown=function() {

this.childNodes[1].innerHTML=english[this.number];

this.childNodes[1].style.fontStyle= "normal";

this.childNodes[1].style.color= rgb(155, 102, 102);

}

phrases[i].onmouseup=function() {

this.childNodes[1].innerHTML=french[this.number];

this.childNodes[1].style.fontStyle="italic";

thischildNodes[1].style.color="#000";

}

}

}



function swapFE(e) {

var phrase=eventSource(e);

if (IE) phrase.attachEvent("on"+ mousedown, swapFE);

else if (DOM) phrase.addEventListener(onmousedown, swapFE, false);

var phrasenum=parseInt (phrase.innerHTML.previousSibling);

phrase.innerHTML.nodeValue=english[phrasenum - 1];

phrase.style.fontStyle="normal";

phrase.style.color=rgb(155, 102, 102);

}





function swapEF(e) {

var phrase=eventSource(e);

if (IE) phrase.attachEvent("on"+ mouseup, swapEF);

else if (DOM) phrase.addEventListener(onmouseup, swapEF, false);

var phrasenum=parseInt (phrase.innerHTML.previousSibling);

phrase.innerHTML.nodeValue=french [phrasenum - 1];

phrase.style.fontStyle="italic";

phrase.style.color="black";

}

Open in new window

0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33712736
Actually, the double-quotes are correct.
It should be

2 cases where normal"  had no starting double-quote.
1 case where rgb...)" had no starting double-quote.

function eventSource(e) {

   var IE=document.attachEvent ? true:false;

   var DOM=document.addEventListener ? true: false;

   if (IE) return event.srcElement;

   else if (DOM) return e.currentTarget;

}



function setUpTranslation() { 

var phrases=document.getElementsByTagName ("p");

for (var i=0; i < phrases.length; i++) {

phrases[i].number = i; 

phrases[i].childNodes[1].innerHTML = french[i];

phrases[i].childNodes[1].style.fontStyle = "italic";

phrases[i].childNodes[1].style.color = "#000";



phrases[i].onmousedown=function() {

this.childNodes[1].innerHTML=english[this.number];

this.childNodes[1].style.fontStyle= "normal";

this.childNodes[1].style.color= "rgb(155, 102, 102)";

}

phrases[i].onmouseup=function() {

this.childNodes[1].innerHTML=french[this.number];

this.childNodes[1].style.fontStyle="italic";

thischildNodes[1].style.color="#000";

}

}

}



function swapFE(e) {

var phrase=eventSource(e);

if (IE) phrase.attachEvent("on"+ mousedown, swapFE);

else if (DOM) phrase.addEventListener(onmousedown, swapFE, false);

var phrasenum=parseInt (phrase.innerHTML.previousSibling);

phrase.innerHTML.nodeValue=english[phrasenum - 1];

phrase.style.fontStyle="normal";

phrase.style.color="rgb(155, 102, 102)";

}





function swapEF(e) {

var phrase=eventSource(e);

if (IE) phrase.attachEvent("on"+ mouseup, swapEF);

else if (DOM) phrase.addEventListener(onmouseup, swapEF, false);

var phrasenum=parseInt (phrase.innerHTML.previousSibling);

phrase.innerHTML.nodeValue=french [phrasenum - 1];

phrase.style.fontStyle="italic";

phrase.style.color="black";

}

Open in new window

0
 

Author Comment

by:NannaG
ID: 33712810
Ok, I made those corrections, Thank You,  but I still do not see my content - Pleae see the attached img
IMG.docx
0
 
LVL 3

Expert Comment

by:VeganBen
ID: 33712854
I haven't been through all your source code, but this line stands out for two reasons:

phrase.innerHTML.nodeValue=french [phrasenum - 1];


phrase.innerHTML will be fine.. you don't need "nodeValue"
and the space between "french" and the square brackets has to go.

In the English half of it:
phrase.innerHTML.nodeValue=english[phrasenum - 1];


just remove the "nodeValue"
0
 

Author Comment

by:NannaG
ID: 33712875
I've made the additional nodevalue removal - no changes though ??
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:VeganBen
ID: 33712891
can we see where you instantiate and populate the french and english arrays?
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 33712893
Instead of making corrections, can you just use http:#a33712736 as your js file?
It works for me as-is.
0
 

Author Comment

by:NannaG
ID: 33712905
I am reviewing my files also, do I need to send you anything other files - I have .css also
0
 

Author Comment

by:NannaG
ID: 33712915
Hum?  Do you think this is a browser issue? I'm using vista,  IE 7
0
 

Author Comment

by:NannaG
ID: 33713004
Well I'll be!! I changed to my laptop , Windows 7 and guess what - yep - it does work: Thank you so much for taking your time to assist me. Your Great!!
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33713042
I was just firing up Windows 2008 and IE8 to have a look, but I'm glad it worked out for you.

Regards
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 39
Popup to change image and store url in database 2 30
Enter key on html form page 11 47
How can i create a customized Login page based on Wordpress ? 8 27
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now