简体   繁体   English

从另一个调用一个 javascript

[英]calling one javascript from another one

I have got a question.我有个问题。 Is that possible to call a javascript from another one.是否可以从另一个调用 javascript。 If it is, can anyone tell me how to do that?如果是的话,谁能告诉我该怎么做?

What I want to achieve is basically: I have got a php page.我想要实现的基本上是:我有一个 php 页面。 I do not want to put all the code here.我不想把所有的代码都放在这里。 It contains google map api js.它包含谷歌 map api js。 I have written classes like Marker and MarkerManager.我编写了诸如 Marker 和 MarkerManager 之类的类。 I want to keep them in another javascript file so I can call them from php.我想将它们保存在另一个 javascript 文件中,以便我可以从 php 调用它们。

To do this, I need to call google map api js from the js I have written which includes Marker and Manager class.为此,我需要从我编写的 js 中调用 google map api js,其中包括标记和管理器 class。

mytest.js (call google map api js) Marker MarkerManager mytest.js (调用谷歌 map api js) Marker MarkerManager

main.php (call mytest.js) main.php(调用 mytest.js)

I hope this explains what I want to do.我希望这能解释我想要做什么。

Thanks in advance.提前致谢。

Simply include your file after the map js file and you should be fine.只需在 map js 文件之后包含您的文件,就可以了。

Just include multiple script files in your page in whatever order they need to be run:只需按照需要运行的任何顺序在您的页面中包含多个脚本文件:

<script type="text/javascript" src="mytest.js"></script>
<script type="text/javascript" src="xxxxx.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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