jspodisus Posted November 13, 2009 Share Posted November 13, 2009 Hi, Is it possible to reference php variables in an external javascript file? If I paste the javascript directly into my html page I can, but when I place the code into the file the php is not being parsed. Many thanks in advance Link to comment https://forums.phpfreaks.com/topic/181365-php-in-external-javascript-file/ Share on other sites More sharing options...
trq Posted November 13, 2009 Share Posted November 13, 2009 You would need to configure your server to parse *.js files as php. Probably not the best idea but it can be done via .htaccess. Link to comment https://forums.phpfreaks.com/topic/181365-php-in-external-javascript-file/#findComment-956713 Share on other sites More sharing options...
PFMaBiSmAd Posted November 13, 2009 Share Posted November 13, 2009 Or name the file .php (there is nothing magic about .js for an extension name.) Link to comment https://forums.phpfreaks.com/topic/181365-php-in-external-javascript-file/#findComment-956830 Share on other sites More sharing options...
jspodisus Posted February 4, 2010 Author Share Posted February 4, 2010 You would need to configure your server to parse *.js files as php. Probably not the best idea but it can be done via .htaccess. i have done this. but its not solution to my problem. Um, it is. Maybe your have done something wrong. Post some relevant code. Link to comment https://forums.phpfreaks.com/topic/181365-php-in-external-javascript-file/#findComment-1006707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.