Beginner JavaScript Question

Started by
0 comments, last by gamechampionx 16 years ago
I'm pretty new to &#106avascript and I've got a question about how it handles reloads. I have an onload function call set up in a body tag of an HTML file and it calls the function fine when the page is loaded but when you hit reload, it's not recalled. For some reason it's on a problem in Firefox and in IE it seems to be working just fine. Any help is appreciated.
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!
Advertisement
Here's my code:

<html><head><script language="JavaScript">function getTitle(filename){   var nameArray = filename.split("/");   var index = nameArray.length - 2;   if(nameArray[index].indexOf(".") > -1)   {      return "Ethereal Divine";   }   else   {      return nameArray[index];   }}function updateTitle(){   //document.write("<table border width=100%>");   //document.write("<tr width=100%>");   //document.write("<td width=10%><img src=\"darthvader.jpg\" width=100%></td>");   //document.write("<td width=80%><center><font color=\"red\"><h1>" + getTitle(parent.frames[2].location.href) + "</h1></font></center></td>");   //document.write("<td width=10%><img src=\"Wolf.jpg\" width=100%></td>");   //document.write("</tr></table>");   document.write("<center><font color=\"red\"><h1>" + getTitle(parent.frames[2].location.href) + "</h1></font></center>");}</script></head><script></script><body bgcolor="black"><script language="JavaScript">updateTitle()</script></body></html>


I've moved the call out of onload but it still produces strange results - it seems to work on the first run in Firefox and it works fine in IE but refresh kills it in Firefox (title is not rendered).

Also, if I take out the document.write comment and put in the others, I'm attempting to create a table, which IE blows up horizontally, violating all the td constraints which I would expect it should be forced to follow since they're specifically stated in the table declaration.

The page is referenced within a frame from my index.html file, and parent.frames[2] represents the main body document.

Any help is appreciated.
Check out Drunken Brawl at http://www.angelfire.com/games6/drunken_brawl!

This topic is closed to new replies.

Advertisement