November 13, 200718 yr Hello again! Im not that familar with JS, I want to start by optimizing my site from tips from another post on this forum. I have a big chuck of text on my site which calls the time and date in JS,I want to tidy this up - how would I call this with an include file from JS? Your help if greatly appreciated as always!
November 13, 200718 yr Not sure what you're asking. You want to get the time and date in JS? Or you want to fetch text from a file in JS?
November 13, 200718 yr do you mean like how a css file is included in the head? if yes then you would place the script in a .js file and then use this in the head: <script type="text/javascript" src="file.js"></script> But if you mean like a php include file because your JS is in the body, then that is done the same way as any php include file would be created and you just need to place the script into a different document and then use: <?php include("js_thing.php"); ?> In your HTML file Well at least I would imagine that it would be as JS is client side scripting so the browsers would read it once the serverside php script had placed it into the HTML....never tried it but I can't see a reason for this not to work
November 14, 200718 yr Author Sorry should have been more clear tt, Thanks dizi thats what I was after! <script type="text/javascript" src="file.js"></script> cheers
Create an account or sign in to comment