-2

1 つの Javascript 関数と 1 つのボタンを持つ localhost/site/index.php があるとします。

<html>
<head>
    <meta charset="utf-8" />
    <title>Page Title</title>
<script type="text/javascript">
    function my_function(){
        alert('Hello eveeryone!');
    }
</script>


</head>

<body>

<button type="button" onclick="my_function();" />Here is my button</button>

</body>
</html>

my_function()ボタンをクリックせずに実行する方法はありますか?

編集: 問題のより良い説明: localhost/site/script.php を使用して、localhost/site/index.php にある上記の my_function をトリガーできますか?

4

3 に答える 3