471,090 Members | 1,414 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,090 software developers and data experts.

Calling functions in different documents

Hello people, my first post here... *wave*

I need to know how to call a function in a different document. At the
moment I've tried onFocus but I'm kinda in over my depth. Perhaps if I tell
you what I want to do you can give me the process and I'll go figure out the
code?

My site is divided into two frames, top frame for navigation, bottom frame
for displaying content (called "top" and "main" respectively).

"top" contains 6 images within 6 seperate anchors, that I use as buttons to
switch between sections, the sections being displayed in "main". When the
mouse is over an image, it changes because I use "OnMouseOver", similarly
for "OnMouseOut".

Here is where I get stuck. I want a different image to be displayed as the
relevant button in "top" depending on which main section is loaded into
"main".

I was hoping to solve this by using "onLoad=" in each of the main pages for
each section, that will call a function in "top.html" to cycle through the
list of images changing the relevant image depending on the content of
"main".

I can see an inherent problem here, I have to make every page (could be
hundreds! - nightmare) call this function.

Is there any help you can offer please?

Kind regards,
Steve :)
Jul 20 '05 #1
3 4186
"Twinkletoes" <no****@nospam.noviagra> writes:
I can see an inherent problem here, I have to make every page (could be
hundreds! - nightmare) call this function.
Lots of work, yes.
Is there any help you can offer please?


How about changing the image when you click on the button?
Clicking will initiate the loading of the main frame, so you can change
the image of the button right away.

This will *not* work if you follow a link in the main page to another
section. If that is possible, you will need code on the page in the
main frame to update the menu.
Ok, if you are desperate, you can make the top frame check the
location of the main frame every second, and then update the images
accordingly.

setInterval(function(){testLocation(parent.frames['main'].location);},1000);

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
In a flash of pure inspiration, Lasse Reichstein Nielsen declared:
"Twinkletoes" <no****@nospam.noviagra> writes: How about changing the image when you click on the button?
Clicking will initiate the loading of the main frame, so you can
change the image of the button right away.

This will *not* work if you follow a link in the main page to another
section. If that is possible, you will need code on the page in the
main frame to update the menu.


Ah, this sounds like the way to go.

Thank you very much.
Steve :)
Jul 20 '05 #3
In a flash of pure inspiration, Lasse Reichstein Nielsen declared:

setInterval(function(){testLocation(parent.frames['main'].location);},1000);

I can't seem to be able to call my function in a page in a different frame.

http://www.leicesterchurchmusic.org/index.html shows my frame definitions
and the function GetPageName(), which works fine. From within this function
I'm trying to call a function in 'top.html' that exists in the frame called
'top'. I'm doing this:

function GetPageName() {
strFullPath = new String(parent.main.location);
arrayJustFileName = strFullPath.split("/");
strFileName = arrayJustFileName[arrayJustFileName.length-1];
arrayName = strFileName.split("."); //0 element is just the name
window.parent.top.test(arrayName[0]);
return arrayName[0];
}

http://www.leicesterchurchmusic.org/top.html contains the function test().
Here it is:

function test(page) {
alert(page);
}

When this function exists in the same document it works fine, but not when I
move it to another one. What am I doing wrong?

Thanks,
Seve :)
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Asapi | last post: by
3 posts views Thread by Scupper | last post: by
2 posts views Thread by Daniel Lidström | last post: by
4 posts views Thread by Edwin Gomez | last post: by
10 posts views Thread by sulekhasweety | last post: by
1 post views Thread by Martin Rubey | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.