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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript not working in Safari or Firefox, but fine in IE.

Status
Not open for further replies.

loveshacl

Technical User
Apr 29, 2008
3
Can anyone give me any clues on this one:

Can anyone help me please (i am quite a novice, but having fun learning). Im not sure if this is an ASP problem, a javascript problem or a browser problem.

Firstly, everything i have written works fine in IE7 and beta IE8. My pages do not work however in Safari or Firefox, and please dont beat me, but i use Frontpage to write my site, and i use iframes as ive not discovered how to do this any differently!

So the issue is this, i have a large database of music, on selecting an item from the menu, frame 1 gets populated with song titles, on clicking one of the song titles, another frame is fpopulated wtih content, images and text, and a 3rd frame is populated with release and chart information and a 4th frame is populated with reviews of that record.

You can see it in action here :
In IE, you can pull down an artist, etc and the first frame populates with content, select a title and the middle frame popualtes, then click on a picture or hyperlink and the thrid frame populates.

In Firefox and Safari, i can only get the first list appearing.

Ive installed Firebug but i don't understand the error.

But, i think i've narrowed it down to the Javascript where i set the frames.

<script language="javascript">
function setframes(m,t,b)
{
parent.document.getElementById("I2").src = m
parent.document.getElementById("I3").src = t
parent.document.getElementById("I4").src = b
}
</script>


this is then called in on the page by the following line:

Response.Write("<a target=""_self"" href=""javascript:setframes('title.asp?Title=" & Server.HTMLEncode(objRS("TITLE")) & "&format=" & Server.HTMLEncode(objRS("ALBUMSINGLE")) & "','chartdetails.asp?Title=" & Server.HTMLEncode(objRS("TITLE")) & "&format=" & Server.HTMLEncode(objRS("ALBUMSINGLE")) & "','../../../reviews/reviews.asp?Title=" & Server.HTMLEncode(objRS("TITLE")) & "');"">" & trim(UCASE(objrs("Title"))) & "</a><br>")

Firebug gives me the error report of parent.document.getElementbyID("i2") has no properties.

it obviously does though in IE.

Any clues or help to a novice would be really appreciated!

Steve
 
The URL you've posted does not work.

That aside, my guess is that you have elements named "I2", "I3", etc, rather than with an ID of "I2", "I3", etc.

If this is the case, then give the elements an ID (given you're asking for them by ID), and you should be sorted.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
It's exactly as I suspected. Your source code has:

Code:
<iframe [!]name="I2"[/!] width="381" height="476" marginwidth="1" marginheight="0" scrolling="no" border="0" frameborder="0" src="../xmas.htm">

So you've given the frame a NAME but you're asking for it by ID:

Code:
parent.document.getElement[!]ById[/!]("I2")

So, as mentioned, you need to modify your NAMEs to be IDs. Or, the other method would be to get a reference to the frame some other way (i.e. getElementsByName).

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I've now set the frames to say name="I1" and ID="I1"

and left the get ElementByID.

This appears to have fixed everything.

I tried the getElementsByName but none of the browsers liked it that way round.

Thanks for your help!
 
getElement[red]s[/red]ByName returns an array, not a single element like getElementById. You'd have to rewrite your code to access the first element of the array if you use getElementsByName.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top