...

View Full Version : Excessing Another File HTML Codes



Marcell
12-07-2010, 04:46 PM
Hi I need to access and edit html codes that belong to another file.

index.html


<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,
:confused:

Philip M
12-07-2010, 05:20 PM
Not sure what you mean by "another file". You must give each link an id.


<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

Socrates
12-07-2010, 05:34 PM
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.

Marcell
12-09-2010, 02:54 AM
Oh let me explain more.
These codes are in index.html:

<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:

<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?

Philip M
12-09-2010, 10:15 AM
Assuming that help.html is a secondary window,


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.

Marcell
12-09-2010, 02:13 PM
Actually I'm using frameset. God, this is complicated.

Marcell
12-10-2010, 03:00 PM
Anybody noes how to handle frameset?

Philip M
12-10-2010, 05:00 PM
http://www.cross-browser.com/talk/inter-frame_comm.html


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

Marcell
12-11-2010, 01:42 AM
Thanks Phil, that helps a lot. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum