Computer Hope

Internet & Networking => Web design => Topic started by: tooNewBlue on July 07, 2010, 10:32:12 AM

Title: .txt to display in tooltip?
Post by: tooNewBlue on July 07, 2010, 10:32:12 AM
I have a feeling this is a simply answer but it never hurts to make sure. I do not want to have to re-write the info in each .txt file i have to correspond to each of my store images. i was thinking re-save them all as .html but then i would still have to open each one so might as well just copy and paste to the google spreadsheet.

oh wait what is it javascript or css that would allow me to reference the .txt file to show its content in the tooltip below the enlarged image?
Title: Re: .txt to display in tooltip?
Post by: kpac on July 07, 2010, 01:04:50 PM
Javascript can do it.

Code: [Select]
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "http://www.mywebsite.com/textfile.txt", true);
txtFile.onreadystatechange = function() {
  if(txtFile.readyState === 4) {
    if(txtFile.status === 200) {
      allText = txtFile.responseText;
      lines = txtFile.responseText.split("\n");
    }
  }
}
txtFile.send(null);

The variable "allText" is what you want to use.