javascript - How to use Super Global PHP variables inside JS file -


this question has answer here:

in javascript file i've if statement , code inside it. , i'm trying use super global variable inside js function.

here php code embedded inside javascript function:

if(typeof window.history.pushstate == 'function') {     window.history.pushstate({}, "hide", '<?php echo $_server['php_self'];?>'); } 

$_server['php_self'] variable stands 3-parametr of js function.

one more thing: when write code inside somefile.php it's working fine. i'm gonna put partition of code inside external js file , include it. how can achieve this?

as long have php parse - appending .php @ end of filename, if you're using apache - should fine. can load javascript files end in php <script src="test.js.php" />.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -