Click to See Complete Forum and Search --> : is there an include() function?
Da Warriah
12-31-2002, 11:33 AM
is there an include() function in JavaScript, so i dont have to enclose a separate file's contents in document.write(''); ?
id like to be able to simply use an include() function, similar to PHP, that will allow me to just put plain text in a .txt file, instead of JScript code as well...is there any way that this is possible?
khalidali63
12-31-2002, 11:45 AM
I don't think so,other then the src attribute in the script tag,but who knows IE might already have come up with something like this..:-)
Khalid
Charles
12-31-2002, 11:51 AM
Originally posted by Da Warriah
is there an include() function in JavaScript, so i dont have to enclose a separate file's contents in document.write(''); ? No, and it's no great loss. Remember, one in ten users do not use JavaScript. JavaScript "includes" are bad; very bad. Use server side includes or the IFRAME element. Or declair an external entity in the Document Type Definition and pre-process your file.
Da Warriah
12-31-2002, 01:54 PM
alright then, thats fine...
i was just wondering, because im working on a news script, using php, but i wanted to give another option for those whose servers dont recognize index.php as a default page, or they already had their site up as index.html...but ive now got it set up so if they choose php, it will "include" the news, and if they choose javascript, it will write the news in the text file with the document.write(''); in place...
oh and about the 1 in 10 users who dont use JavaScript...they can work it out with the web designer themselves...not my problem:D