How to link to named iframe

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
warrenfab
Beginner
Beginner
Posts: 4
Joined: Mon Jan 24, 2005 9:27 pm

How to link to named iframe

Post by warrenfab »

I have the following problem;

A main page, for example "about.php".
On this page, there is an iframe, which has been given a name, example:

<iframe src="http://www.mysite.com/about_nuts.php" name="about" scrolling="no" frameborder="no" align="left" height = "190px" width = "500px"></iframe>

As one selects different items from the "about" menu, it should open the particular src page in the static page which never changes (in this case about.php). So you click on about_nuts.php and it loads into the iframe on the about.php page. If you click on "about_fruit.php" it opens that page in the iframe on the about.php page.

I hope the scenario sketched here is clear.

What I need to know is, how do I create the links and targets within the menu_data.js file? (assuming this is where I would change it).

Many thanks for any help forthcoming.

Warren

User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Warren,

Probably the simplest thing to try would be to set the target property in the aI() string:

Code: Select all

aI("text=About Fruit;url=about_fruit.php;target=about;");
Cheers,

Kevin
warrenfab
Beginner
Beginner
Posts: 4
Joined: Mon Jan 24, 2005 9:27 pm

I've tried that, but here's what it does

Post by warrenfab »

Hi Kevin

I've tried that, but it opens the "about.php" page and the contents of "about_fruit.php" in the iframe space.

Any ideas?
warrenfab
Beginner
Beginner
Posts: 4
Joined: Mon Jan 24, 2005 9:27 pm

Dumb Dumb Dumb

Post by warrenfab »

was all my fault....it works like a dream.

Thanks again Kevin, much appreciate the help.

Regards,
Warren :}
warrenfab
Beginner
Beginner
Posts: 4
Joined: Mon Jan 24, 2005 9:27 pm

Drat, there's always something else

Post by warrenfab »

The "target=about" does not work for FireFox, it just opens the "about_nuts.php" page in a new window.

What do I do to get it to work in FireFox?

Thanks again,
Warren
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Warren,

Haven't really worked a lot with IFrames and Milonic, but there is a discussion in this sample page about it. It describes a function called openIFrame() that may work across all of your target browsers (again, I don't know for sure. But it's an alternative).

Cheers,

Kevin
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

I'm not sure what exactly you are trying to do so, here are some suggestions:

1. if there is an iframe on each page and each has a different name
a. you can link to them if you are opening particular links on particular pages. Assume opening a particular link in the about.php

Code: Select all

aI("text and so on; url=javascript:openIFrame('about','http://www.whateverurl.com/aboutus.php');
This would open the aboutus.php page in the iframe named about, if of course you're on the page that has the iframe named about.
b. if you have a differently named iframe on different pages and you want all the links to be able to open in any of those iframes I think you might have to have some kind of function that says something about if iframe named about, contact, home, inventory, sales, then assume name tempiframe. Sorry, I don't know function language. Anyway, you're trying to get it to read any iframe name and 'pretend' the name is tempiframe, then you would code all the links as javascript:OpenIframe('tempiframe and so on. I don't even know if that is possible.

2. You can name each iframe as tempiframe [or whatever name you choose] on all the pages and then javascript:OpenIframe('tempiframe etc. and the links would open in the iframe of whichever page you are on.

Also, you should not only have name=about but also id=about for the iframe identification. I think that might fix the FireFox issue [maybe]

You also need to have the iframe function in the head of the page

Code: Select all

function openIFrame(IFrameID, URL){
   ifId=gmobj(IFrameID)
   ifId.location.href=URL // Opera Bug Fix. ifId.src=URL}
Finally, and I don't really understand the coding, but you might try naming the iframe about but using id=tempiframe for the javascript:OpenIframe code in the menu. I'm not sure you can name it one thing and have the id as another since I don't use iframes, but if that were the case it would mean you could id all iframes as one name and name each as what you want it to be?

Ruth
Post Reply