Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript (Safari)- value undefined when iframe calls parent function

Status
Not open for further replies.

workmode1

Programmer
Oct 28, 2008
4
Hello,
I have created a website where the iframe content calls a function on the parent to display data on the main page. I have tried top.functionCall(), parent.functionCall(), and a number of other permutation and I get the same result on Safari.

The specific error is:
Value Undefined (result of expression parent.setPopup) is not an object.

This works in Firefox (Win and Mac), Google, IE, and Opera, but not at all in Safari. I can not think of a work around. Any suggestions?

The site is The specific page is listed on the bottom menu as Mantelscapes. It popups up an iframe with the following call :

<a href="javascript:void(0);" onclick="top.setPopup(1);"><img...></a>

The function I am calling is as follows (it is listed on the Parent page):

function setPopup(popup_number) {
var popup1 = document.getElementById("popup1");
var popup2 = document.getElementById("popup2");
var popup3 = document.getElementById("popup3");
var popup4 = document.getElementById("popup4");
var popup5 = document.getElementById("popup5");
var popup6 = document.getElementById("popup6");
var popup7 = document.getElementById("popup7");
var popup8 = document.getElementById("popup8");

popup1.style.display = "none";
popup2.style.display = "none";
popup3.style.display = "none";
popup4.style.display = "none";
popup5.style.display = "none";
popup6.style.display = "none";
popup7.style.display = "none";
popup8.style.display = "none";

if (popup_number == 1) {
popup1.style.display = "inline";
}
else if (popup_number == 2) {
popup2.style.display = "inline";
}
else if (popup_number == 3) {
popup3.style.display = "inline";
}
else if (popup_number == 4) {
popup4.style.display = "inline";
}
else if (popup_number == 5) {
popup5.style.display = "inline";
}
else if (popup_number == 6) {
popup6.style.display = "inline";
}
else if (popup_number == 7) {
popup7.style.display = "inline";
}
else if (popup_number == 8) {
popup8.style.display = "inline";
}
return true;
}

I would love a solution that fits my design, but I will take all suggesions. Thank you in advance.
 
That was one of the iterations I already tried. I am looking to see if there is any kind of work around.
 
Well... it works just fine for me. I'm using Safari 3 (MacOSX). I'll test it on Safari 3 under Windows XP later today to be sure it works there too.

Check the version of Safari you are using and maybe look at testing it on a modern version of Safari - and let us know how you go!

Cheers,
Jeff

[tt]Visit my blog [!]@[/!] Visit Code Couch [!]@[/!] [/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Thanks for the reply. Do I understand properly that you tried the website and it worked for you or are you saying you have used top.window.functionCall() in your experience and it worked fine. If you have a different example that works for you, I would love to try it.

I have a Mac Book Pro (5 months old) with Safari 3.1.2.
 
On my last post I transposed the top and window. I am using window.top.functionCall(). Just wanted to point that out.
 
I visited the URL you provided and had no problem - the iframed content showed fine.

Cheers,
Jeff

[tt]Visit my blog [!]@[/!] Visit Code Couch [!]@[/!] [/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top