Forum Moderators: travelin cat
I'm working on a very simple javascript "Orders" page for a photographer friend of mine. He wants potential customers to see a small thumbnail of the desired print whenever they select a matching title from a dropdown list. I've coded a sample page using tables and an <iframe> that works in all browsers (PC and Linux, including Konqueror) but breaks in Safari. My tester (I don't own a Mac) reports that she can see the initial "Select Image" graphic in the <iframe>, but it doesn't change when choosing a new title from the list. The complete "Orders" test page is here:
<snip>
and the "stripped" version that has only the orders / thumbnail code is here:
<snip>
I had read elsewhere on the web that Safari has problems with any type of "document.all" code, which this page uses, but if I change the initial function:
function ShowWebSite(val)
{
document.all.myFrame.src=val;
}
to something like
function ShowWebSite(val)
{
val=document.getElementByID("myFrame").src
}
everything breaks -- the code no longer works in any browser. Can anyone here give me a clue to what I'm doing wrong?
Thanks in advance.
-- Darrell
[edited by: engine at 2:42 pm (utc) on April 2, 2007]
[edit reason] No urls, thanks. See TOS [webmasterworld.com] [/edit]
I don't know for sure what is broken with your code. However, it does matter what side of the equal sign your different values are on. If
valis on the right side of the equal sign in the working code, I would expect to see it on the right side of the equal sign on the changed code. So in your broken code, you are setting the val variable to equal the current value of the iframe's src rather than setting the iframe's src to the current value of val.
Also, the code you posted is missing a semicolon (although that's probably just a copy and paste error).
Try:
function ShowWebSite(val)
{
document.getElementByID("myFrame").src = val;
}
missing a semicolon
That shouldn't matter (at the end of a line). JavaScript considers line endings to be statement terminators.
function ShowWebSite(val)
{
document.getElementByID("myFrame").src = val;
}
for the "document.all" line, but it broke in all my PC browsers, so I'm assuming it won't work in Safari either.
<frustration> If Apple is really concerned that we develop for Safari, do they maintain any kind of "official" help line to iron out these kinds of problems? </frustration>
Again, tx for the help.
-- Darrell