我们可以从另一个内部javascript函数调用内部javascript函数吗?

时间:2015-04-08 09:20:26

标签: javascript jquery html

您好我是javascript的新手。我怀疑我们可以从另一个内部javascript函数调用内部javascript函数吗?

例如:

考虑两个html a.html和b.html我想从a.html调用b.html javascript函数,我想传递一个参数。

a.html

<html>
<head>
<script type="text/javascript">
function abc(variable){
xyz(variable);//where xyz function in b.html
}
</script>
</head>
<body>
</body>
</html>

b.html

<html>
    <head>
    <script type="text/javascript">
    function xyz(variable){
    alert('message::'+variable);
    }
    </script>
    </head>
    <body>
    </body>
    </html>

这可能还是有其他方法可以做到这一点???

1 个答案:

答案 0 :(得分:0)

是的,这是可能的。

  • 您可以使用html imports
  • XHR,使用getElemntsByTagName选择脚本,并评估其内容
  • 育儿

我不推荐任何。

相关问题