Help me with javascript

Discussion in 'JavaScript' started by vlbknl2, Oct 3, 2010.

  1. #1
    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
     
    vlbknl2, Oct 3, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    I suggest you to write the function m(a) in a .js file and include it into 2 files (1.html and 2.html).
     
    s_ruben, Oct 4, 2010 IP
  3. vlbknl2

    vlbknl2 Active Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #3
    I've saved. js file, but still not, I'd use a file to control a function in a different file
     
    vlbknl2, Oct 4, 2010 IP
  4. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #4
    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:
     
    s_ruben, Oct 4, 2010 IP
  5. vlbknl2

    vlbknl2 Active Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #5
    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>
     
    vlbknl2, Oct 4, 2010 IP