28-08-2008

Javascript Frames

This page is an overview of frame properties and methods as they can be accessed by Javascript.

Accessing the document:

frames['frameName'].document.innerHTML

Accessing variable in sibling frame via the parent ( - frameset):

top.frames[0].varName = 1;
//or 
parent.frames[0].varName = 1;

Access function in sibling frame:

top.frames[0].doWhatever(3);
//or in parent
parent.doWhatever(3);

Changing source or location / access the url of another frame in the same frameset:

//in a frameset (or document):
 
alert(parent.frames[1].location.href)
 
frames['iframe_name'].location.href = 'newpage.html';
 
//in a document.body:
document.getElementById('iframe_id').src = 'newpage.html';

Comments:

Your comment:

»

 

[x]