PDA

View Full Version : Dynamic anchor in IFrame


el_joker
01-09-2006, 09:17 PM
6413
Hi all,
this is my first post here... I have been reading the post but don't seem to find an answer to my problem. So here it goes...

I have attached a zip file with 3 html in it (IFrame + Data and Dynamic.html)

---------------------
I want to set a specific item to be viewed on my IFRame by calling the anchor value. Thats fine in my attached files IFrame.html calls Data.Html with a specific anchor in this case 8

<IFRAME
SRC = "C:\Data.html#8"
WIDTH=300 HEIGHT=50 >
</IFRAME>
---------------------
My problem is when I want to do this dynamically (Dynamic.html)
I'm able to set the SRC data in the IFrame without specifying a file, but I don't seem to find the way to specify the anchor value.

Can somebody help me :confused:

scoutt
01-09-2006, 09:34 PM
the page you loa din the iframe has to have a anchor. meaning you can't load .html#8 if the page being loaded doesn't have a anchor called 8.

if yo uwant it to laod when you click on a link ti is the samething as you got in the src.

<a href="Dynamic.html#8">

but 8 has to be an anchor with that name.

el_joker
01-09-2006, 09:44 PM
The way im using im creating both IFrame and Data dynamically, so its not possible to write into disc html files. That's why I code Dynamic.html the way I did...

scoutt
01-09-2006, 09:47 PM
then what do you mean dynamic? how are you creating it? what serverside language are you working with?

el_joker
01-09-2006, 09:51 PM
I'm creating html for Sharepoint

I generate html, but need to show only a certain part of the page and show a specific part so thats why I use an IFrame

Everything is pretty much dynamic, I post files just to show my problem but in reality I only have an html to render in Sharepoint.

Thx

scoutt
01-09-2006, 10:26 PM
then add an anchor to the code. but I am lost as to what you mean by creating html for sharepoint

el_joker
01-09-2006, 11:38 PM
Html in Sharepoint is a webpart...

did you run the files in my zip file

Can you see a way to dynamically specify SRC=MyFile.html#anchorValue ?

scoutt
01-10-2006, 09:37 AM
I don't see a zip file.

welshsteve
01-10-2006, 09:54 AM
Firstly, the anchor tags in data.html are outside the table cells, so this is not going to work correctly to begin with. Give me a minute and I'll take a look at this

welshsteve
01-10-2006, 10:03 AM
This is what data.html should look like

Code for data.html

<table cellSpacing="1" cellPadding="0" width="100%" border="1">
<tbody>
<tr>
<td><A name="1">1</a></td>
</tr>
<tr>
<td><A name="2">2</a></td>
</tr>
<tr>
<td><A name="3">3</a></td>
</tr>
<tr>
<td><A name="4">4</a></td>
</tr>
<tr>
<td><A name="5">5</a></td>
</tr>
<tr>
<td><A name="6">6</a></td>
</tr>
<tr>
<td><A name="7">7</a></td>
</tr>
<tr>
<td><A name="8">8 </a></td>
</tr>
<tr>
<td><A name="11">11</a></td>
</tr>
<tr>
<td><A name="12">12</a></td>
</tr>
<tr>
<td><A name="13">13</a></td>
</tr>
<tr>
<td><A name="14">14</a></td>
</tr>
</tbody>
</table>


I don't quite know what you are trying to achieve though. Are you simply trying to display from the anchor #8 onwards in the iframe? Iframe.html does that if data.html is coded as I put above. I don't quite see the relevance of dynamic.html

el_joker
01-10-2006, 12:29 PM
HI Data.html and IFrame.html would be a static project where I know how to set a specific view on the data.

But my project is to do that on a dynamic way. By running Dynamic.html you can see I have my data inside the IFrame but I'm not able to specify a # value

welshsteve
01-10-2006, 01:20 PM
Not even if dynamic.html is coded as below?

<body onload="myLoad()">

<div id="myCalendarHtml" style="display :none;">

</div>
<iframe id="myIFrameCalendar" src="data.html#8" width=700></iframe>

<script language="Javascript">

function myLoad(){

myIFrameCalendar.document.open();
myIFrameCalendar.document.write(document.getElementById("myCalendarHtml").innerHTML);
myIFrameCalendar.document.close();

}

</script>
</body>

scoutt
01-10-2006, 03:00 PM
el_joker, where is the #8 coming from? you have to send something to it or i ain't dynamic. what you are doing doesn't make since, it will never load as you never send anything to it. you have to give the iframe a name, you have to target the iframe in order to load something into it. dynamic or not, it won't work as you have it now.

I didn't see the zip file cause I didn't recognise it as one.

el_joker
01-10-2006, 04:11 PM
Run this code you will see what I mean. THe #8 is an example of a anchor to target in the IFrame viewable part.


<body onload="myLoad()">

<div id="myCalendarHtml" style="display :none;">

<TABLE cellSpacing="1" cellPadding="0" width="100%" border="1">
<TBODY>
<TR>
<TD>1</TD><A name="1"></A>
</TR>
<TR>
<TD>2</TD><A name="2"></A>
</TR>
<TR>
<TD>3</TD><A name="3"></A>
</TR>
<TR>
<TD>4</TD><A name="4"></A>
</TR>
<TR>
<TD>5</TD><A name="5"></A>
</TR>
<TR>
<TD>6</TD><A name="6"></A>
</TR>
<TR>
<TD>7</TD><A name="7"></A>
</TR>
<TR>
<TD>8</TD><A name="8"></A>
</TR>
<TR>
<TD>11</TD><A name="11"></A>
</TR>
<TR>
<TD>12</TD><A name="12"></A>
</TR>
<TR>
<TD>13</TD><A name="13"></A>
</TR>
<TR>
<TD>14</TD><A name="14"></A>
</TR>

</tbody>
</TABLE>

</div>
<iframe id="myIFrameCalendar" width=700></iframe>

<script language="Javascript">

function myLoad(){

myIFrameCalendar.document.open();
myIFrameCalendar.document.write(document.getElementById("myCalendarHtml").innerHTML);
myIFrameCalendar.document.close();

}

</script>
</body>

Pegasus
01-10-2006, 04:20 PM
You can't have the anchors outside the cells. They have to be either before, after or around the interior text.

Peg

scoutt
01-10-2006, 04:31 PM
Run this code you will see what I mean. THe #8 is an example of a anchor to target in the IFrame viewable part.


that is the whole point, you never send #8 to it. not one place. plus all you do is write something that is displayed to none, it will never load as you set it to none.

el_joker
01-10-2006, 04:48 PM
OK so my tag are place correctly.... how do I specify my # value now?

<body onload="myLoad()">

<div id="myCalendarHtml" style="display :none;">
<table cellSpacing="1" cellPadding="0" width="100%" border="1">
<tbody>
<tr>
<td><A name="1">1</a></td>
</tr>
<tr>
<td><A name="2">2</a></td>
</tr>
<tr>
<td><A name="3">3</a></td>
</tr>
<tr>
<td><A name="4">4</a></td>
</tr>
<tr>
<td><A name="5">5</a></td>
</tr>
<tr>
<td><A name="6">6</a></td>
</tr>
<tr>
<td><A name="7">7</a></td>
</tr>
<tr>
<td><A name="8">8 </a></td>
</tr>
<tr>
<td><A name="11">11</a></td>
</tr>
<tr>
<td><A name="12">12</a></td>
</tr>
<tr>
<td><A name="13">13</a></td>
</tr>
<tr>
<td><A name="14">14</a></td>
</tr>
</tbody>
</table>

</div>
<iframe id="myIFrameCalendar" width=700></iframe>


<script language="Javascript">

function myLoad(){

myIFrameCalendar.document.open();
myIFrameCalendar.document.write(document.getElementById("myCalendarHtml").innerHTML);
myIFrameCalendar.document.close();

}

</script>
</body>

el_joker
01-10-2006, 11:05 PM
My last post is the code I want to run, can someone tell me what line of code I need to add to specify in the Javascript my #value??? That's the point of my post...

scoutt
01-10-2006, 11:13 PM
again, you can't load anythign with this

<div id="myCalendarHtml" style="display :none;">
it will always be hidden.

el_joker
01-11-2006, 02:18 AM
Did you try it?

Pegasus
01-11-2006, 02:21 AM
It's not going to matter how your anchor link is written. The page isn't going to show up because you've told the <div> to hide. You'll have to change the display option before anything else will work.

Peg

welshsteve
01-11-2006, 05:05 AM
As Pegasus says, and I said earlier in the thread, you need to move the anchor tags inside the table cells. See the code I posted above.

i.e.

<tr>
<td><a name="1">1</a></td>
</tr>


Also, try using lower case for your tags.

welshsteve
01-11-2006, 05:06 AM
also, make sure that all tag attributes are enclosed in quotes

welshsteve
01-11-2006, 05:32 AM
oops. Sorry about those last two posts, I seem to have fallen behind the thread of posts :~

scoutt
01-11-2006, 01:05 PM
god, i forgot how stupid IE is. yes, that will work el_joker, IE does show the table in the iframe, but it is not suppose to. but as far as I know you can't send it to a anchor without loading it from a url. maybe some of these javascript gurus can assist. all you did was show the table, nothing more.

el_joker
01-12-2006, 04:34 PM
Found a way to do it, I just tested it.
Works find

Here's the code...

<body onload="myLoad()">

<div id="myCalendarHtml" style="display :none;">

<TABLE cellSpacing="1" cellPadding="0" width="100%" border="1">
<TBODY>
<TR>
<TD>1</TD><A name="1"></A>
</TR>
<TR>
<TD>2</TD><A name="2"></A>
</TR>
<TR>
<TD>3</TD><A name="3"></A>
</TR>
<TR>
<TD>4</TD><A name="4"></A>
</TR>
<TR>
<TD>5</TD><A name="5"></A>
</TR>
<TR>
<TD>6</TD><A name="6"></A>
</TR>
<TR>
<TD>7</TD><A name="7"></A>
</TR>
<TR>
<TD>8</TD><A name="8"></A>
</TR>
<TR>
<TD>11</TD><A name="11"></A>
</TR>
<TR>
<TD>12</TD><A name="12"></A>
</TR>
<TR>
<TD>13</TD><A name="13"></A>
</TR>
<TR>
<TD>14</TD><A name="14"></A>
</TR>

</tbody>
</TABLE>
<a href="#1" id="MoveToDate" style="display :none;"></a>
</div>
<iframe id="myIFrameCalendar" width=700></iframe>


<script language="Javascript">

function myLoad(){
myIFrameCalendar.document.open();
myIFrameCalendar.document.write(document.getElementById("myCalendarHtml").innerHTML);
myIFrameCalendar.document.close();
myIFrameCalendar.document.getElementById("MoveToDate").click();
}
</script>
</body>

Pegasus
01-12-2006, 04:36 PM
Your coding isn't quite right. It should be:

<script type="text/javascript">

Peg

welshsteve
01-13-2006, 05:06 AM
Shouldn't the anchor tags also be inside the table cells? As previously mentioned.