1. Is it possible to run a javascript function defined in one frame from another frame?
2. I have heard a few arguments both for and against using frames. What do you think?
Printable View
1. Is it possible to run a javascript function defined in one frame from another frame?
2. I have heard a few arguments both for and against using frames. What do you think?
I dont think it is possible to use a JS function from another frame, but you can use a *.js file... I am not sure how though....
and if you need the TOC of your page to be visible all the time, its easier to use frames then other things, like including it on every page.
That is exactly the reason that I am experimenting with frames - I have a header, and a TOC down the left hand side and both are identical on all pages. Using frames eliminates the need to replicate the header and TOC code in all of the pages (but you know that already - I am still on the learning curve!!!)
I believe that a frames site can cause problems when it comes to the search engines. If a search engine lists one of the "child" pages and you click on that link, then all you see is that particular frame. Any thoughts on how we get around this problem?
Use a 'frames breaker' code. Basically, check if this frame = window.top, and if it is, reload window.top as the index frame. Microsoft's MSDN library frames system is quite complex but works well, and I would suggest you dissect their code.
you could use a certain meta tag,
I am not sure what it is called or how to use it, but there is one metatag that excludes the page from search engines.
Dennis: I think you are referring to <META name="ROBOTS" content="NOINDEX, NOFOLLOW">. I am already using this in a couple of pages in my site. One of them is a customised 404-Missing Link page (I don't like to advertise my errors!!!), and the other is the redirect page following submission of a form - I don't want anyone starting off from there.
However, I would like all of the other pages to have a sporting chance with the search engines.
Parksie: Could you expand a bit on your frames breaker code? What is the code to check the current frame id? Perhaps an example? Thanks in advance.
[Edited by Michael on 08-13-2000 at 05:42 AM]
Put this in the <head> section of your page:
What this does, is if this is a sub-frame page, it breaks out and moves to the top. Therefore, if you replace the last location.href with the page you want, then it will move to the index.Code:<SCRIPT LANGUAGE="JavaScript">
<!--
if (window != top) top.location.href = location.href;
-->
</SCRIPT>
As for checking the frame id, use window.name (I think).
But what if I want the page to beloaded in my frames and NOT a new window of how the sites belong to.
He uses the top.location.href != top to test this. Is there some way of by passing this check?
Thanks
First of all it is possible to call a function of one frame from another.
it works in IE (dont know about netscape)
something like this:
Code:top.framename.functionname;
that code should work in NS also