Trouble with iframes?

O

oscar.redondo

I started with Javascript one month ago and I have a doubt.

I have a table with 2 iframes and and 3 links that activate de
Tab1_OnChange code.

Unfortunatelly, after the first iframe all getElementById (as this one
shown) makes an error.

What's wrong?

Thks in advance!

<html >
<head id="tagHead"><title>
Untitled Page
</title>
</head>
<body>

<form name="form2" method="post" action="gwcTabControlEjemplo.aspx"
id="form2">
<script>
function Tab1_onChangeTab(id)
{
var x;

x=top.document.getElementById('Tab1_fraContenido_2');
alert(x.id);
}
</script>

<TABLE border="0" width="100%" height="100%" cellpadding="2"
cellspacing="0" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<TR><TD height="10px" /></TR>
<TR><td nowrap="" id="Tab1_tdPestaña_1"
style="height:20px;" class="Tab_TabDown">
<a href="javascript:Tab1_onChangeTab(1, 'http://
www.google.es')" title="aa" class="ms-toolbar">google</a></td><td
class="Tab_TabFiller"><img src="/Blank.gif" width="3px" /></td>
<td nowrap="" id="Tab1_tdPestaña_2" style="height:20px;"
class="Tab_TabDown">
<a href="javascript:Tab1_onChangeTab(2, 'http://
www.fib.upc.es')" title="aa" class="ms-toolbar">fib</a></td><td
class="Tab_TabFiller"><img src="/Blank.gif" width="3px" /></td>
<td nowrap="" id="Tab1_tdPestaña_3" style="height:20px;"
class="Tab_TabDown">
<a href="javascript:Tab1_onChangeTab(3, 'http://
www.gelos.es')" title="aa" class="ms-toolbar">gelos</a></td><td
class="Tab_TabFiller"><img src="/Blank.gif" width="3px" /></td>
<TD width="100%" class="Tab_TabFiller"><img src="/Blank.gif" /></
TD></TR>
</TABLE>

<iframe src="http://www.google.es" frameborder="0" style="height:
100%;width:100%" id="Tab1_fraContenido_1"/>

<iframe src="http://www.iblnews.com" frameborder="0" style="height:
100%;width:100%" id="Tab1_fraContenido_2"/>

</body>
</html>
 
A

ASM

En réponse à (e-mail address removed) qui écrivit, en date du : 4/09/07
11:28, le message suivant :
I started with Javascript one month ago and I have a doubt.

It is not only a question of JS but an html problem ...
Unfortunatelly, after the first iframe all getElementById (as this one
shown) makes an error.

What's wrong?
<html >
<head id="tagHead"><title>
Untitled Page
</title>
</head>
<body>

<form name="form2" method="post" action="gwcTabControlEjemplo.aspx"
id="form2">
<script>

not <script> but <script type="text/javascript">

<script type="text/javascript">
function Tab1_onChangeTab(id, url)
{
var x=top.document.getElementById('Tab1_fraContenido_'+id);
x? alert(x.id) : alert(x);
}
<TABLE border="0" width="100%" height="100%" cellpadding="2"
cellspacing="0" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
(...)


<iframe src="http://www.google.es" frameborder="0" style="height:
100%;width:100%" id="Tab1_fraContenido_1"/>

No !
your iframe has no end (no closing tag) so the second one is :
- not existing
ou
- included in first one

<iframe blah>Your browser can't display iframes</iframe>


<iframe id="Tab1_fraContenido_1"
src="http://www.google.es" frameborder="0"
style="height:100%;width:100%"/>
Your browser can't display iframes, follow this link :
<a href="http://www.google.es">Google</a>
</iframe>
 
O

oscar.redondo

En réponse à (e-mail address removed) qui écrivit, en date du : 4/09/07
11:28, le message suivant :


It is not only a question of JS but an html problem ...




not <script> but <script type="text/javascript">

<script type="text/javascript">
function Tab1_onChangeTab(id, url)
{
var x=top.document.getElementById('Tab1_fraContenido_'+id);
x? alert(x.id) : alert(x);
}


No !
your iframe has no end (no closing tag) so the second one is :
- not existing
ou
- included in first one

<iframe blah>Your browser can't display iframes</iframe>

<iframe id="Tab1_fraContenido_1"
src="http://www.google.es" frameborder="0"
style="height:100%;width:100%"/>
Your browser can't display iframes, follow this link :
<a href="http://www.google.es">Google</a>
</iframe>

Ok. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top