• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3013
  • Last Modified:

check if frame exists

I've to reload another frame:
parent.frames[8].location = "page2.htm";
this scripts is included in all my pages with an .js file

But sometimes there's another frameset and the specific frame does not exists. So the scripts should only work when the frame exists

I tried something like:

if (parent.frames[8].name == 'framename')
     {
     parent.frames[8].location = "page2.htm";
     }

But still get an error when there's no frame 8.
0
moswa
Asked:
moswa
  • 3
1 Solution
 
CJ_SCommented:
var w = window.open("", "framename");
if(w)
{
   alert("frame is present!")
   w.location = "page2.htm"
}
0
 
moswaAuthor Commented:
I don't want to use window.open. If there's no frame[8] just don't run the script, not try to create the page.

I had the script working few months ago, but lost the script. Its was something like

if (parent.frames[8].name == 'framename')
    {
    parent.frames[8].location = "page2.htm";
    }

or

if (parent.frames[8]=true)
    {
    parent.frames[8].location = "page2.htm";
    }
0
 
CJ_SCommented:
see above. it does NOT open a window!
0
 
CJ_SCommented:
if(parent.frames && parent.frames[8] && parent.frames[8].name=="framename")
  parent.frames[8].location="page2.htm";
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now