468,107 Members | 1,333 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

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

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[i][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>

Jul 20 '05 #1
4 1377
Treetop wrote:
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.


<--snip-->
document.IFRAMENAME.setup(links[aNum]);


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

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

--
Randy

Jul 20 '05 #2

"Randy Webb" <hi************@aol.com> wrote in message
news:8t********************@comcast.com...
Treetop wrote:
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.


<--snip-->
document.IFRAMENAME.setup(links[aNum]);


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

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

--
Randy


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.

Jul 20 '05 #3
Treetop wrote:
"Randy Webb" <hi************@aol.com> wrote in message
news:8t********************@comcast.com...
Treetop wrote:
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.


<--snip-->
document.IFRAMENAME.setup(links[aNum]);


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

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

--
Randy

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

--
Randy

Jul 20 '05 #4
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[i][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]);

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dom | last post: by
3 posts views Thread by Randell D. | last post: by
4 posts views Thread by Marina Ferguson | last post: by
2 posts views Thread by Terry | last post: by
2 posts views Thread by Brett Robichaud | last post: by
9 posts views Thread by Arash Dejkam | last post: by
4 posts views Thread by Daz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.