Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:47

Targeting to iframe


Poster: Theme
Dated: Friday April 15 2005 - 14:32:53 BST

Hi,

if i want my links to open in iframe, how do I do that. Iframe is named as iframe.

Another question is about links. Do I put the complete url, http://www.mydomain.com/gallery.html or just /gallery.html


Poster: Ruth
Dated: Friday April 15 2005 - 15:16:44 BST

In order to open the menu in an IFRAME you will need a custom JavaScript function. The function is called openIframe and it's parameters are IFrameID and URL

Code:
function openIFrame(IFrameID, URL){
ifId=gmobj(IFrameID)
ifId.location.href=URL // Opera Bug Fix. ifId.src=URL
}


The function gets placed on the web page and then in the menu data file you'd code the aI string:

Code:
aI("text=Open Google in IFrame;url=javascript:openIFrame('tempiframe,'http://www.google.com'")


For more information on opening windows and frame see sample 11

Ruth

Still something to ask...


Poster: Theme
Dated: Friday April 15 2005 - 16:29:51 BST

:oops: I"m sorry, my English skills and computer skills aren´t good enough...

aI("text=Open Google in IFrame;url=javascript:openIFrame('tempiframe,'http://www.google.com'")
Where do I exactly place that??
And which parts of the codes do I have to replace with my own iframe names etc.

Thnx a lot, I think I´ll handle this after your reply.
And do I have to place complete url in links?


Poster: Ruth
Dated: Friday April 15 2005 - 17:19:48 BST

Hi,

Don't worry about it. My computer skills aren't that good either :)

OK, the function gets placed on the web page that has the iframe, just like it is, just copy and paste it. You said you named your iframe, iframe. I think you might want to change that, maybe tempiframe, or myiframe. I'm not a code person, but the function says things like openIFrame etc, so maybe you want to make the name different than iframe alone.

In the menu_data.js file you will have to 'call' the function in the aI string. You'll see all of the places you list your text and pages begin with aI. For the function to be called so the page will open in the iframe you put this in the url section
Code:
url=javascript:openIFrame('name of your iframe','http://address');
So let's say the text on the menu is My Poetry, and the url is poems2u.com, and the iframe is named myiframe, the aI string would be:
Code:
aI("text=MyPoetry;url=javascript:openIFrame('myiframe','http://www.poems2u.com/');");


Hope that helps.

Ruth


Poster: Theme
Dated: Saturday April 16 2005 - 0:07:46 BST

Oh god, am I getting a headache :?: :cry:
Back to basics:

1. function openIFrame(IFrameID, URL){
ifId=gmobj(IFrameID)
ifId.location.href=URL // Opera Bug Fix. ifId.src=URL
}

In which section of my page am I supposed to place that code and which tags must I use, <script>???

2. aI("text=MyPoetry;url=javascript:openIFrame('myiframe','http://www.poems2u.com/');");

That´s what you posted and this is from sample11:

aI("text=Open Google in IFrame;url=javascript:openIFrame('tempiframe,'http://www.google.com'")

I´ve found too many different ways and I really am confused now 8O

EDIT:

Here´s what I got now between the body tags of my page;

<script>
function openIFrame(IFrameID, URL){
ifId=gmobj(IFrameID)
ifId.location.href=URL // Opera Bug Fix. ifId.src=URL
}
</script>


This is my Iframe:

<iframe
src="1joukkue.html" id="tempiframe" name="tempiframe"
frameborder="0" height="420" width="500"></iframe>


This is the link:

aI("text=Google;url=javascript:openIframe('tempiframe','http://www.google.com/');");


Poster: Ruth
Dated: Saturday April 16 2005 - 1:11:48 BST

Sorry I forgot the script tags in front of and after the function which as I said gets put on the html page that has the iframe, I think you could put it in the head, or after the body tag. I assume it has to be before the iframe itself someplace though, so that it is 'working' before the iframe is loaded. I believe on the sample page it's in the middle of the page.

Code:
<script>function openIFrame(IFrameID, URL){
ifId=gmobj(IFrameID)
ifId.location.href=URL // Opera Bug Fix. ifId.src=URL
} </script>


As to the different ways, they are not different ways, they are the same way, just different text, iframe names and urls. So, just make subsitutions for the text you have, the name of your iframe and the url you want to open in the iframe.

Code:
aI("text=Whatever Text You Want to Show on the Menu;url=javascript:openIFrame('the name of your iframe','the url of the page to open in the iframe');");
Make sure you have all the little ' and , and ( ) and ;

I used to get real frustrated when having to use a function because I would get overwhelmed with all the stuff in it that I didn't understand. I still can't write a function but someone explained one to me once and it helped to at least get me to understand some of the simpler ones, to at least find the name of the function and what it's supposed to do and it's parameters. In this one, its name is openIFrame, then in between the () it's telling you that you put the name of the iframe [whatever you have named it,] and the url you are going to open in that iframe, so what you are doing in the url section of the menu_data.js file is:

1. telling the menu that when the link is clicked it's going to use a javasript function url=javascript:
2. putting in the name of the function url=javascript:openIFrame
3. putting in the parameters of the function, those are the things listed between the ( ) url=javascript:openIframe('name of your iframe','page url you want to load');

If you still have trouble, please post the text you want to show in the menu, the name of your iframe, the url of the page you want to load into the iframe.

Hope this helps.

Ruth


Poster: Theme
Dated: Monday April 18 2005 - 13:38:20 BST

Hmm, it works now...

The script in my page is now:

<script>
function openIFrame(iFrameId,winURL)
{
ifId=gmobj(iFrameId)
ifId.src=winURL
}

</script>

I wonder why it doesn´t work with the script that you posted and which I found in samples?!?!


Poster: Ruth
Dated: Monday April 18 2005 - 15:09:32 BST

Hi,

I don't know. But, looking at the source of the page with the sample, the code actually used is the same as the one you just posted :?

Ruth


Poster: Theme
Dated: Monday April 18 2005 - 15:33:56 BST

That´s what I did, looked at the source of the page and copied the code from there. Makes me wonder why there is different script in sample than in the page itself. Anyway, it works perfectly now. Thanks for your advices and for your patience :D