Interaction design • webdevelopment • web art • photography
2 JavaScript questions | pro.hu,arpa,dave, 050909 23:48 |
---|---|
Hy! I have two questions. If you know the answer, please write. Thanks. first: It is possible to switch CSS stylesheets with JavaScript? (e.g. it is 3 radiobuttons, and the site looking is depend on the switch of them 1-style_1.css 2-style_2.css 3-style_3.css) second: It is possible to manage a .txt file with JavaScript? (e.g. I would make a html page, that one part is random generated from the .txt with JavaScript) Sorry, if my sentences are unintelligible, but my english is very bad... :(( Thank you very much! Vielen Dank! Koszonom szepen! (Hu) |
|
dsl51B6C2F8.pool.t-online.hu |
Re: 2 JavaScript questions | Calm_Pear, 050910 07:00 |
---|---|
Hi Dave, The first question seems simple but requires some elaborate JavaScript; luckily someone already wrote something for us. Check this link: http://www.alistapart.com/articles/alternate/ The answer for the second question is more complex, I’ll cook up some script and post it at a later time. |
|
h103091.upc-h.chello.nl |
Re: 2 JavaScript questions | Calm_Pear, 050910 08:21 |
---|---|
You can use JavaScript to read from a file on the server, you cannot write to the file nor can you delete the file, move the file or do whatever with it. You will need server side scripting to do that like php. Okay, three samples below, the first one uses an array and writes random from the array to a div element. The second sample uses the xmlhttp object to read from a file, splits the content and randomly displays the content in the div element. The last sample also uses the xmlhttp object but reads from different files on the server and displays the content in the div element. Note: the xmlhttp object will not work with older browsers or any other funky browser nobody uses anyway. Internet Explorer 5+ and Mozilla 1.3+ are sure to be able to do the samples. This was tested on Explorer 6.0 and Firefox 1.0.6. Some more info can be found here: http://jibbering.com/2002/4/httprequest.html |
|
h103091.upc-h.chello.nl |
Re: 2 JavaScript questions | Calm_Pear, 050910 08:21 |
---|---|
|
|
h103091.upc-h.chello.nl |
Re: 2 JavaScript questions | Calm_Pear, 050910 08:22 |
---|---|
content.txt Apple, Banana, Orange, Pear |
|
h103091.upc-h.chello.nl |
Re: 2 JavaScript questions | Calm_Pear, 050910 08:26 |
---|---|
Don't forget to upload three text files with all three having something different in it: 1.txt 2.txt 3.txt The code above assumes that the files (content.txt, 1.txt...) are in the same directory as the above html files are. If the files need to be somewhere else just change the following part
Or change the array:
Good luck! |
|
h103091.upc-h.chello.nl |
Re: 2 JavaScript questions | pro.hu,arpa,dave, 050919 12:45 |
---|---|
Thank you very much!
|
|
dsl51B663B5.pool.t-online.hu |
Pages: 1 |
---|