当函数在单独的PHP文件中定义时,调用JavaScript函数onclick按钮事件
How do you call a JavaScript function from one PHP file that is defined in another PHP file?
如何从另一个PHP文件中定义的一个PHP文件中调用JavaScript函数?
3 个解决方案
#1
This is a best guess at what you want :)
这是你想要的最佳猜测:)
I am assuming you have two php files, that end up being sent to the browser as html. The solution is to move your javascript function to an separate (external) javascript file and include them in both of the php files (not with the phps include. See below). That way you can call the javascript function from both files.
我假设你有两个php文件,最终以html的形式发送到浏览器。解决方案是将你的javascript函数移动到一个单独的(外部)javascript文件,并将它们包含在两个php文件中(不包括phps include。见下文)。这样你就可以从两个文件中调用javascript函数。
All you need to do is move the function to an new file, then put the link to the external javascript file in the head of the html code (in the php file)
你需要做的就是将函数移动到一个新文件,然后将链接放到html代码头部的外部javascript文件中(在php文件中)
<script type="text/javascript" src="js_src.js"></script>
更多相关文章
- python (9)统计文件夹下的所有文件夹数目、统计文件夹下所有文件数
- Python 内置函数及excel操作
- Python3 函数式编程(高阶函数)
- python中range()函数的用法--转载
- Python3入门(六)——函数式编程
- 使用Python写HTML 文件使用jinja2中的模板
- Python执行系统命令:使用subprocess的Popen函数
- python传递列表作为函数参数
- Python读取修改ini配置文件[ConfigParser]