简体   繁体   中英

Calling Javascript function in an external file through php file?

Javascript code (In another file in the same directory):

function js(str)
{
 alert(str);
}

PHP code(in current file):

<?php
echo '<script  type="text/javascript" src="C:\xampp2\htdocs\ARD\call_jsfunc_diff_page.js">  </script>';
echo '<script>js("hello!!")</script>';
?>

I have checked on many links on the internet, i think i'm doing the right way, but the javascript function js(str) doesn't get called !!

Can somebody help me please ??

Before you edited the question: You called the function js but you are trying to call the func function.

Access to local hard disks is also problematic. Use a relative URI and access the .js over HTTP instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM