I want to call the javascript function of one web page from another web page. Suppose I have a function
myFunction()
A.html
B.html
onclick
myFunction()
onclick
B.html
A.html
A.html
<script>
function myFunction() {
document.getElementById("my_contents").style.display="block";
}
</script>
B.html
<a href="Contents.html#entertainment" target="ccc" onclick="myFunction()">
<h4>Entertainment</h4></a>
What you're trying to do is impossible because HTML pages don't make "local" functions available to other webpages.
To solve your issue:
Create a file called script.js
.
Place your javascript function inside it without the <script>
tags.
In the <head>
tag of both your web pages, add <script src="path/to/script.js"></script>