Linking to a file within a frame...possible?

They have: 26 posts

Joined: Mar 2000

My site uses frames. Is there any way to link to frameset and for it to load a html files other than the 'main' page. The onlyother solution I can see is too create a framset for every page on the site (which kind of defeats the object of the time saving navbar frame Smiling

Thanks

Brendan

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi,

Do you mean this?

<a href="html\descript.html"
target="main">
<a href="html\contact.html"
target="main">

...etc.....
If you do, the above is example links for a navigation bar (in say the 3rd frame of a 3-frame frameset).
The "target" keyword tells the browser in which frame to load the referenced page. Note: you must name the frames for this to work.
If you do not name the frames, you will have to use frames[0]...etc.
If you do not use "target" you will have to use the entire dom -- something like: document.framename.location.href = "something.html" (I could be wrong about the syntax, been a while since I played with frames.)

Hope this helps. If not, let me know.

Vinny

------------------
GrassBlade: cut&paste javascript
The Javascript Place Forums

Where the world once stood
the blades of grass cut me still

They have: 231 posts

Joined: Feb 2000

Could you give us a URL?

They have: 26 posts

Joined: Mar 2000

Sorry my first post was perhaps a bit ambiguous.

The site just uses a simple half split framset, with a navabar and main page. I've allready got the links to load in the correct frame and its been like that for a while. What the problem is, is that when the frame loads it loads the nabar.html and main.html file. Viewing any other file requires navigation from here (using the navbar). But if for example I wanted to link directly to a page called links.html without having to navigate from the main page, if I typed in the URL it appears outside the frameset (which looks and naviagates strangely, especially since he links are all 'targeted' to load within 'main' which doesn't exist). Is there any way to get the 'main' frameset to load with this 'links.html' document within the 'main' frame along with the navbar.html in the navbar frame without writing out a completely new frame?

The reason that I'd like to do this is so I am able to refer people to specific part of the website, but for them to still be able to continue navigation as normal.

Thanks

Brendan

They have: 20 posts

Joined: May 2000

Yes, you can do this with javascript. Try this putting this on your links.html:

<script language="javascript">
if (top==self) location.href="Insert URL of main frameset here"
</script>

Remember to put this within the header tag.

------------------
HotRedirect - Free URL Redirection and Unlimited E-mails

They have: 26 posts

Joined: Mar 2000

I've tried the 'hcshim' javascript, A kind of a referal javascript like this was what I had in mind, but it refers the page to the main frameset which still loads up the default 'main' page in the 'main' frame rather than the 'refering' page.

The idea is that when search engines spider the site, they spider pages which normally would be viewed inside the frameset. Clicking on the link from the search engine loads a page which is out of its frameset. I guess i'm looking for a script that I could put on a page wich will load a frameset 'around' the page when the visitor loads it out of its frameset.

Thanks for your help,

Brendan

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.