I have one file have name: 1.html writed code: <HEAD> <TITLE>WINDOWS</TITLE> <SCRIPT LANGUAGE="JavaScript"> function openWindow(url,name) { popupWin = window.open(url, name, "scrollbars=yes,width=800, heigth=200 "); } function m(a) { popupWin = alert('Click ok'); } </SCRIPT> </HEAD> <BODY> <a name="123" href="javascript:m(this.a)">oPen</a>,<br> <input type="button" value="-link-" onclick="m(this.a)"> </BODY> </HTML> ------------------- i want to write one file with name 2.html can control fuction m(a) of file 1.html when open 2.html will run m(a) and show "click ok" Help me! Thanks everyone
I suggest you to write the function m(a) in a .js file and include it into 2 files (1.html and 2.html).
You have to do somethink like this: Create a file.js file and write this code into it function openWindow(url,name) { popupWin = window.open(url, name, "scrollbars=yes,width=800, heigth=200 "); } function m(a) { popupWin = alert('Click ok'); } Code (JavaScript): The content of the file 1.html is <HEAD> <TITLE>WINDOWS</TITLE> <SCRIPT SRC="file.js"></SCRIPT> </HEAD> <BODY> <a name="123" href="javascript:m(this.a)">oPen</a>,<br> <input type="button" value="-link-" onclick="m(this.a)"> </BODY> </HTML> HTML: And the file 2.html content is <HEAD> <TITLE>WINDOWS</TITLE> <SCRIPT SRC="file.js"></SCRIPT> </HEAD> <BODY> <a name="456" href="javascript:m(this.a)">Open</a> </BODY> </HTML> HTML:
Thank you very much.But you have misunderstood my mind already! I want to run 2.html direct function of the file that you click on the file 1.html 2.html there appears always "click ok" button without anything ! I tried like this, but still not run <script> function load() { Win2= window.open("nc thanh cong lenh Win1.location.href=javascriptm(this.a).html","Hieu"); } Win2= window.open("nc thanh cong lenh Win1.location.href=javascriptm(this.a).html","Hieu1232"); Win3= window.open("1.html"); Win3.location.href="javascript:m(this.a)"; </script>