Solved

check if frame exists

Posted on 2002-07-12
4
2,925 Views
Last Modified: 2012-08-13
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
Comment
Question by:moswa
  • 3
4 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 7148638
var w = window.open("", "framename");
if(w)
{
   alert("frame is present!")
   w.location = "page2.htm"
}
0
 
LVL 1

Author Comment

by:moswa
ID: 7148653
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
 
LVL 22

Expert Comment

by:CJ_S
ID: 7148724
see above. it does NOT open a window!
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 50 total points
ID: 7148726
if(parent.frames && parent.frames[8] && parent.frames[8].name=="framename")
  parent.frames[8].location="page2.htm";
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question