Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Excessing Another File HTML Codes

    Hi I need to access and edit html codes that belong to another file.

    index.html
    Code:
    <tr>
              <td width="120"><a href="pic1.html" rel="lyteframe[group]" title="" rev="width: 780px;  height: 480px; scrolling: no;"><img src="images/pic1_tn.jpg" width="120" height="60" border="0"></a></td>
              <td width="120"><a href="pic2.html" rel="lyteframe[group]" title="" rev="width: 780px;  height: 480px; scrolling: no;"><img src="images/pic2_tn.jpg" width="120" height="60" border="0"></a></td>     
    </tr>
    Example:
    For the above I want to change the pic1.html to pic6.html. I have a file Helper.html that will change this value on a click of a button. How do I go about doing that?

    Regards,

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Not sure what you mean by "another file". You must give each link an id.

    Code:
    <tr>
              <td width="120"><a id = "first" href="pic1.html" rel="lyteframe[group]" title="" rev="width: 780px;  height: 480px; scrolling: no;"><img src="images/pic1_tn.jpg" width="120" height="60" border="0"></a></td>
              <td width="120"><a id = "second" href="pic2.html" rel="lyteframe[group]" title="" rev="width: 780px;  height: 480px; scrolling: no;"><img src="images/pic2_tn.jpg" width="120" height="60" border="0"></a></td>     
    </tr>
    
    <input type = "button" value = "Change href" onclick = "changehref()">
    
    <script type = "text/javascript">
    function changehref() {
    document.getElementById("first").href = "pic6.html";
    }
    
    </script>

    "Of course mistakes are made. Some of them are even accidental". - Channel 5

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it is a completely separate file on the server, you're likely going to have to use some type of file parsing. Be warned this is no small project, and you're likely better off including the code from the two files into one so that they can be changed using the above method.

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Oh let me explain more.
    These codes are in index.html:
    Code:
    <tr>
              <td width="120"><a id = "first" href="pic1.html" rel="lyteframe[group]" title="" rev="width: 780px;  height: 480px; scrolling: no;"><img src="images/pic1_tn.jpg" width="120" height="60" border="0"></a></td>
              <td width="120"><a id = "second" href="pic2.html" rel="lyteframe[group]" title="" rev="width: 780px;  height: 480px; scrolling: no;"><img src="images/pic2_tn.jpg" width="120" height="60" border="0"></a></td>     
    </tr>
    While these codes are in help.html:
    Code:
    <input type = "button" value = "Change href" onclick = "changehref()">
    
    <script type = "text/javascript">
    function changehref() {
    document.getElementById("first").href = "pic6.html";
    }
    </script>
    They are both in the same domain. How do I reference the getElementById?

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Assuming that help.html is a secondary window,

    Code:
    window.opener.document.getElementById("first").href = "pic6.html";
    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • Users who have thanked Philip M for this post:

    Marcell (12-10-2010)

  • #6
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Actually I'm using frameset. God, this is complicated.
    Last edited by Marcell; 12-10-2010 at 01:59 PM.

  • #7
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question

    Anybody noes how to handle frameset?

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    http://www.cross-browser.com/talk/inter-frame_comm.html

    Code:
    var elem = top.Frame2.document.getElementById('elementIdInFrame2');
    elem.href = "pic6.html";

  • #9
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks Phil, that helps a lot.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •