Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Call Parent Frame JavaScript

Posted on 1998-07-08
5
Medium Priority
?
242 Views
Last Modified: 2012-05-04
--- I have a frame HTML page: ----------------------------------------------
<frameset rows="74,*">
 <frame src="header.html" name=header>
 <frame src="body.html" name=body>
</frameset>

--- in the header.html 'script' section I have functions: ------------------
function click(imageLoc)
function headerRollOut(num)
function headerRollOver(num)
function navigatorRoll(mousePos)

Now for the question.  I want to call the functions in the header.html (header) page from the html in the body.html (body) page.  That is I don't choose to repeat all my functions that I wrote in my header.html in my body.html.  I don't want the same code in both areas.  Is there something like:
         parent.frames['header'].click(imageLoc)
that will call a javascript function from another frame?  Please help!  Thanks so much!  How the heck do I do this??
0
Comment
Question by:rw263
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1266351
yes, it should work as you described.

maybe it is even easier to write the functions (and varibles if you want) in the frameset-page.

================

<script>
var MyVar1 = ...

function MyFunction1() {}
function MyFunction2() {}
function MyFunction3() {}
</script>

<frameset rows="74,*">
<frame src="header.html" name=header>
<frame src="body.html" name=body>
</frameset>

=================

you can call from the frames by:

parent.MyFunction1()

and access variables like

newvar = parent.Myvar1


0
 

Author Comment

by:rw263
ID: 1266352
I kept the script in the header.html and called the script from the body.html like: onMouseOver="parent.header.navigatorRoll('Over')" and it doesn't work.  If I have in the header.html onMouseOver="navigatorRoll('Over')" it works.  How do I call the SAME script from a different frames html?

0
 
LVL 1

Expert Comment

by:cutetech
ID: 1266353
It supposes to be work nice. Can you post your script? It may be help.
0
 
LVL 6

Accepted Solution

by:
alamo earned 800 total points
ID: 1266354
I am assuming that "parent.header.navigatorRoll()" does not work. It should - I duplicated your setup (from what you posted) and it worked for me, both Netscape and IE3.

I have seen things like this before, though, where due to the way the html is written "parent" doesn't get the job done. (Usually the error will be something like "parent.header has no properties"). Try the following:
top.header.navigatorRoll()
or
parent.parent.header.navigatorRoll()

If neither of these works... please be more specific. What error does it give?
0
 

Author Comment

by:rw263
ID: 1266355
Sorry, my bad, the original suggestion did work, I didn't know how to recall my bad reply.  I originally had local problems and that is what caused it.  Thanks for all the help!!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

722 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