JavaScript getElemet help …

by Miguel on December 23rd, 2009

How can i get some information (considering that we open the 3 files using the Index.Html)
When i use “javascript:alert(document.getElementsByTagName(’title’).length);” it retrieves “0″ but each frame has it´s own title.

How can i access it ?

P.S. - This code is divided in 3 files (Index.html, Frame1.php and Frame2.php)

Syntax: HTML
Show lines - Hide lines - Show in textbox - Download
Index.php code file
----------------------------------------------------------------------
<html>
 
<frameset cols="*, 165" frameborder="0" framespacing="0" border="0">
 <frame frameborder="0" marginwidth="5" marginheight="5" border="0" src="Frame1.php" name="FrameMain" />
 <frame frameborder="0" scrolling="no" noresize marginwidth="7" marginheight="0" src="Frame2.php" name="FrameSecondary" />
</frameset>
 
</html>
----------------------------------------------------------------------
Frame1.php code file
----------------------------------------------------------------------
<html>
<head>
 <title>This is the main frame</title>
</head>
 
<body>
 <div id="PriUm">
  <div>
   This is line one
  </div>
  <div id="PriDois" class="PriUmClass">
   This is line two
  </div>
   <div class="PriDoisClass">
    This is line tree
   </div>
  <div class="PriTresClass">
   This is line four
  </div>
   <div>
    This is line five
   </div>
 </div>
</body>
 
</html>
----------------------------------------------------------------------
Frame2.php code file
----------------------------------------------------------------------
<html>
<head>
 <title>This is the secondary frame</title>
</head>
 
<body>
 <div id="SecUm">
  <div>
   This is line one
  </div>
  <div id="PriDois" class="SecUmClass">
   This is line two
  </div>
   <div class="SecDoisClass">
    This is line tree
   </div>
  <div class="SecTresClass">
   This is line four
  </div>
   <div>
    This is line five
   </div>
 </div>
</body>
 
</html>

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS