Load content from text

Discussion in 'JavaScript' started by 2mk_atspace, Dec 7, 2005.

  1. #1
    Can i automatic load content from file(*.txt) to my page using javascript.
     
    2mk_atspace, Dec 7, 2005 IP
  2. 313i

    313i hummmmmm. No clue

    Messages:
    1,338
    Likes Received:
    73
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm also looking for a solution to this. If anyone knows please let us know :)
     
    313i, Dec 15, 2005 IP
  3. 313i

    313i hummmmmm. No clue

    Messages:
    1,338
    Likes Received:
    73
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Found a script below that I just got done messing with. I've screwed with it alittle so it may not be exactly what your looking for but its doing good for me :) If you just want to has one thing printed out insted of having 2-5 different random things just make the var_num_of_quotes=0 and delete the if (quotes==1) section.

    past the code below into a text file and call it whatyouwant.js

    /* This JavaScript (Random Quotes) developed by Scott Clark
    The Source is available at http://www.clarksco.com/blog/
    Copyright 2005 Clark Consulting */
    
    var num_of_quotes = 3;
    quotes = Math.floor (num_of_quotes * Math.random());
    
    if (quotes==0) {
    body="\"customer quote\"";
    name="customer name";
    linktitle="customer site name";
    linkurl="customer url";
    
    }
    
    if (quotes==1) {
    body="\"2nd customer quote \"";
    name="2nd customer name";
    linktitle="2nd customer site name";
    linkurl="2nd customer URL";
    
    }
    
    document.write('<div align=center><i>');
    document.write(''+ body +'');
    document.write('<br><b>'+name+'<br><a href='+'"'+linkurl+'"'+'target="'+'_blank"'+'>'+linktitle+'</a></i></b>');
    document.write('</div>');
    Code (markup):
    Then in your page you can call the script to print out what ever is in the code.

    <script language="javascript" src="js/quotes.js"></script>
    Code (markup):
    Make sure you go to http://clarksco.com/blog/?cat=2&paged=2 and actually download the script to see it before I messed with it and to also get the readme cause you'll want to read it.

    Hope it helps.
    313i
     
    313i, Dec 15, 2005 IP