在第一页:
<button type="button" onclick="myFunction()">click</button>
然后在另一个页面上:
myFunction() {
alert("working");
};
这是接收页面。
- 所有基本标签
<script>
function alert() {
alert("The Link Has Been Successful");
}
</script>
问题是:如何调用另一个页面上的另一个函数来提醒该页面<button onclick="????">
?
<body>
<button onclick="???" type="button">Alert on the other page</button>
</body>
最佳答案
Call a function in one page when the function is on another page
这是不可能的。所述函数
的定义必须存在于当前页面上才能执行。
标准方法是extract your function into it's own (or global) JavaScript file 。然后在需要使用它的页面上引用它。
关于javascript - 当函数在另一页时调用该函数在一个页面中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13324932/