Main.php
Code: Select all
<script>
var testVar = "<?php echo '$testphpvar'; ?>";
callExternalFunction();
</script>
Code: Select all
function callExternalFunction(){
alert(testVar);
}
Code: Select all
<script>
var testVar = "<?php echo '$testphpvar'; ?>";
callExternalFunction();
</script>
Code: Select all
function callExternalFunction(){
alert(testVar);
}
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Jake Stantz" />
<script type="text/javascript">
var thevalue = "Hello world";
</script>
<script type="text/javascript" src="externalfile.js"></script>
<title>Untitled 3</title>
</head>
<body>
Time to try it.
</body>
</html>
Code: Select all
alert(thevalue);
Code: Select all
$(document).ready(function() {
testingVar = "This is a test!";
externalCallTest();
});
Code: Select all
(function($){
externalCallTest = function() {
alert(testingVar);
};
})(jQuery);