pic and text to iframe, works in IE but not Netscape

T

Treetop

I have code that works in IE but not Netscape 7+. This code allows me
to have a list of links that bring up an image and description in an
iframe. This works great in IE, however I have users that are
Netscape users.


main page:

var links=new Array();

links[2]=new Array("picture2.jpg","Pic 2 link title","Pic 2 image
title");
links[1]=new Array("picture1.jpg","Pic 1 link title","Pic 1 image
title");

function showImg(aNum)
{
document.IFRAMENAME.setup(links[aNum]);
}

// and so on ...

for (var i=links.length-1;i>=0;i--)
{
document.write('<a href="#" onclick=showImg("'+i+'")>' + links[1] +
'</a><br>');
}





the iframe file:


<script>
function setup(aLink)
{
document.getElementById("pic").src=aLink[0];
document.getElementById("title").innerHTML=aLink[2];

}
</script>
<body>
<p id="title"></p>
<img src="" id="pic">
</body>
 
R

Randy Webb

Treetop said:
I have code that works in IE but not Netscape 7+. This code allows me
to have a list of links that bring up an image and description in an
iframe. This works great in IE, however I have users that are
Netscape users.

document.IFRAMENAME.setup(links[aNum]);

Stop using IE-shortcut-code and it will work in NS7+:

document.frames['IFRAMENAME'].setup(.......);
 
T

Treetop

Randy Webb said:
Treetop said:
I have code that works in IE but not Netscape 7+. This code allows me
to have a list of links that bring up an image and description in an
iframe. This works great in IE, however I have users that are
Netscape users.

document.IFRAMENAME.setup(links[aNum]);

Stop using IE-shortcut-code and it will work in NS7+:

document.frames['IFRAMENAME'].setup(.......);

Thank you for your help.

I changed
document.external.setup(links[aNum]);

with
document.frames['external'].setup(links[aNum]);

and neither browser worked. If you have time, please tell me what I
am missing.
 
R

Randy Webb

Treetop said:
allows me
to have a list of links that bring up an image and description in
an
iframe. This works great in IE, however I have users that are
Netscape users.

document.IFRAMENAME.setup(links[aNum]);

Stop using IE-shortcut-code and it will work in NS7+:

document.frames['IFRAMENAME'].setup(.......);


Thank you for your help.

I changed
document.external.setup(links[aNum]);

with
document.frames['external'].setup(links[aNum]);

and neither browser worked. If you have time, please tell me what I
am missing.

My bad. Change it to window.frames instead of document.frames.

In blank.html:
window.frames['iFrameName'].myFunction('It works');

In blank2.html:

function myFunction(alertMessage){
alert(alertMessage)
}

And it now works in IE6, Opera 7, NS7, Mozilla1.4
 
T

Treetop

It now works for Netscape, but not IE. I do not have enough beer in
the house for this, lol.


--------------------------------
Here is the code in my test1.html file.


<script language="javascript" type="text/javascript">

var links=new Array();
links[2]=new Array("picture2.jpg","Pic 2 link title","Pic 2 image
title");
links[1]=new Array("picture1.jpg","Pic 1 link title","Pic 1 image
title");

function showImg(aNum)
{
window.frames['external'].setup(links[aNum]);
}

for (var i=links.length-1;i>=0;i--)
{
document.write('<a href="#" onclick=showImg("'+i+'")>' + links[1] +
'</a><br>');
}

</script>

<iframe name="external" id="external"
style="width:100%;height:500px" src="picture.html"></iframe>

</body>
</html>


--------------------------------
Here is the code for my iframe file (picture.html)

<script language="javascript">
function setup(aLink)
{
document.getElementById("pic").src=aLink[0];
document.getElementById("title").innerHTML=aLink[2];
}
</script>

<center>
<img src="pic3.jpg" id="pic">
<p id="title">Text for default picture</p>
</center>

--------------------------------
My goal is to have links on a page that will update the iframe with
the image and text from the script. The errors I get from IE 6 are:

Error #1 - When it first loads I get
Error: 'links[...].1' is null or not an object

Error #2 - When I click on a link I get
Object doesn't support this property or method

I used the following line previous and it worked for IE but not for
Netscape, however Error #1 was still there in IE.

document.external.setup(links[aNum]);
in place of
window.frames['external'].setup(links[aNum]);
 

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,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top