0

My scenario is as this:-

parent.html

<html>
<script type="text/javascript" src="myjs.js"></script>
<body>
<a href="./child.html"> child </a>
</body>
</html>

myjs.js

function myFunction() {
  alert("I am an alert box!");

child.html

<html>
<body>
<button onclick="">child button</button>
</body>
</html>

I added JavaScript to the parent HTML and the parent has a link to the child HTML page. I want to call JavaScript function myFunction() from the child without adding the JavaScript in the child HTML. Is it possible to call the JavaScript function from the child without adding

<script type="text/javascript" src="myjs.js"></script>
masiboo
  • 4,537
  • 9
  • 75
  • 136
  • 6
    There's no "parent" and "child" here, they are both simply pages. One has a link which navigates to the other. For any given page, any JavaScript you want to execute would need to be included in or referenced by that page. Taking a step back, what's the goal here? Why can't you put the JavaScript on the page that needs it? – David Nov 13 '19 at 20:35
  • @David, I would ask a question like this, but I have a question ban. His reason is probably because he would like to access local storage from one local file to another. – Chris Nov 13 '19 at 20:51

0 Answers0