tsilenzio Posted July 4, 2007 Share Posted July 4, 2007 Ok this is going to get confusing and i usally make it worse when i explain things but: I have a php page (index.php) which will see if ur logged in, if ur not then it loads up "templates/StarOne/login.htm". by doing: <?php //lines up above require_once("templates/StarOne/login.htm"); //lines below ?> The javascript files I use are in: "templates/--js/blah.js", "../--js/blahblah.js" So in the html files i do: <script src="../--js/blah.js" type="text/javascript"></script> And it will run on my PC with NO PROBLEMS at all however in my index page it loads up the login.htm it wont run the script at all it just goes to the next page. --------------- MY VERSION OF TRYING TO FIX IT (FAILURE HOWEVER) ---------------------- I thought possibly instead of doing to the html files (incase it runs the file from the main directory <script src="templates/--js/blah.js" type="text/javascript"></script> instead of: <script src="../--js/blah.js" type="text/javascript"></script> and it still dosnt work. Any ideas? (By the way all the script does right now is a validation confirm for user input fields) Thank you SOOOO much in advance Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/ Share on other sites More sharing options...
tsilenzio Posted July 4, 2007 Author Share Posted July 4, 2007 If you are very confused on this (because of the way i explain) it let me know and i will try to clear it up the best i can Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-289385 Share on other sites More sharing options...
tsilenzio Posted July 4, 2007 Author Share Posted July 4, 2007 maybe if i do a require_once for the js files it would work then? (Provided the <html><head> settings have been decleared already)? :s Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-289393 Share on other sites More sharing options...
Daniel0 Posted July 4, 2007 Share Posted July 4, 2007 /templates/--js/blah.js if your index.php is in /. If you require(_once) a file, then you don't instruct the browser to get the things there, you include the contents of that file into the current script before it is output. Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-289423 Share on other sites More sharing options...
tsilenzio Posted July 4, 2007 Author Share Posted July 4, 2007 so theres no way to make the person inable to read my code (in JS?) =/ Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-289577 Share on other sites More sharing options...
Daniel0 Posted July 4, 2007 Share Posted July 4, 2007 No, they have to download the code in order for the browser to be able to interpret it. Everything you place on your page (HTML, CSS, Javascript, images etc.) is downloaded by the user to their cache. Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-289588 Share on other sites More sharing options...
tsilenzio Posted July 4, 2007 Author Share Posted July 4, 2007 yea but in .js file if u do: <!-- //code below //--> Then if u try to go to http://www.somesite.com/somefile.js and it has whats mentioned above then the html takes the whole thing as a comment, but in js it works as a file with html ---------------- I think that works for CSS files as well :s Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-289966 Share on other sites More sharing options...
tsilenzio Posted July 5, 2007 Author Share Posted July 5, 2007 nevermind i fixed it doing the require_once actally does work sorry to prove u wrong buddy =/ Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-290055 Share on other sites More sharing options...
Hypnos Posted July 5, 2007 Share Posted July 5, 2007 No, they have to download the code in order for the browser to be able to interpret it. Everything you place on your page (HTML, CSS, Javascript, images etc.) is downloaded by the user to their cache. nevermind i fixed it doing the require_once actally does work sorry to prove u wrong buddy =/ There is no way for javascript to be executed without it being downloaded to the user's browser. Javascript is ran in the browser. Not on the server. Apache/PHP have no idea what your Javascript does. Look at the source to your page from a browser. You will see your javascript in the source. require_once added it. Quote Link to comment https://forums.phpfreaks.com/topic/58361-require_once-javascript-files/#findComment-290081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.