Click to See Complete Forum and Search --> : iframes


ashers
02-06-2003, 08:57 AM
Hi,
I've got a jump box on an html page, but I need it to change in the iframe, at the moment it opens over the top. The code is:-


<iframe src="leishamniasis_2.htm" BORDER="FALSE"
BANNER="FALSE" WIDTH="100%" HEIGHT="500">
</iframe>

<select name="jumpit" onChange="JumpTo(jumpit.options[jumpit.selectedIndex].value)">

<option value="leishamniasis_2.htm#Top" selected>Jump to...</option>

<option value="leishamniasis_2.htm#pathogenesis">
Pathogenesis</option>

</select>

I need the "leishamniasis_2.htm#pathogenesis" to jump down on the page, but within the i frame.

Cheers

Stefan
02-06-2003, 09:32 AM
Mayby you should include the script that you are refering to in the code?

ashers
02-06-2003, 09:36 AM
function JumpTo ( sOption ) {
navigate ( sOption );

Thanks

Charles
02-06-2003, 09:50 AM
Your solution is to rid your self of all that JavaScript that isn't going to work all of the time no matter what you do.

Your IFRAME element should look like:

<iframe src="leishamniasis_2.htm" BORDER="FALSE"
BANNER="FALSE" WIDTH="100%" HEIGHT="500" name="child"><a href="leishamniasis_2.htm">leishamniasis_2.htm</a></iframe>

You FORM tage should look like:

<form action="someScript.pl" target="child">

You'll need to give your OPTION element a name, say "url". And your server side script should look something like:

#!usr/local/bin/perl
use CGI qw (redirect param);
print redirect 'http://www.somesite.com/'.param ('url');

khalidali63
02-06-2003, 09:56 AM
in your jumpTo(url) function do this.

document.iframeName.document.location.href =url;

This should do it.

cheers

Khalid

ashers
02-06-2003, 09:56 AM
What do you mean isnt going to work all the time?
I need it to work on the javascript I've got, not to change it.

Thanks

Charles
02-06-2003, 10:00 AM
I might have mentioned this once or twice, but one in ten users do not use JavaScript - and that number includes people who cannot use JavaScript because of their disabilities.

ashers
02-06-2003, 10:06 AM
I will re-phrase my question then. How can I do this with the javascript I've got as I'm editing a huge site that already exits.

ashers
02-06-2003, 10:07 AM
Thanks khalidali63.
Where exactly should I put this, I'm a bit confussed - long day!
Cheers

khalidali63
02-06-2003, 10:08 AM
I have posted a potential solution to ur problem above already.
Check it out.

ashers
02-06-2003, 10:11 AM
I have but cant get it to work.

Charles
02-06-2003, 10:16 AM
Originally posted by khalidali63
in your jumpTo(url) function do this.

document.iframeName.document.location.href =url;

This should do it.

cheers

Khalid For reasons I've explained elsewhere (http://forums.webdeveloper.com/showthread.php?s=&threadid=1517&highlight=document.location) document.location.href is problematic. Use instead Window.location.href or in this case use document.iframeName.location.href. And if that fails, you might try my method.

khalidali63
02-06-2003, 10:17 AM
If you look at this line of code (its fromyour first post)

<select name="jumpit" onChange="JumpTo(jumpit.options[jumpit.selectedIndex].value)">

onchange event has a method jumpto()
you are passing the currently selected value in the listbox to this jumpTo function.

Look for this function in the JavaScript code and put this line f code in it

document.ifrm.document.location.href =url;

Since you do not have a name attribute set for your iframe,therefore enter this value right after this
<iframe
name = "ifrm"

now your iframe tag should look like this

<iframe name="ifrm" src="leishamniasis_2.htm" BORDER="FALSE"
BANNER="FALSE" WIDTH="100%" HEIGHT="500">
</iframe>

If you are still confused then you might have post atleast your jumpTo function in its entirety here


hope this helps

Khalid

ashers
02-06-2003, 10:23 AM
Thanks, thats what I've been trying to do, I will play around with it more as I still cant get it to work.

This is my jumpto function in its entirety:-

function JumpTo ( sOption ) {
navigate ( sOption);
}

Cheers

khalidali63
02-06-2003, 10:26 AM
ok now I see you have another function in there.

navigate()

..post that here

ashers
02-06-2003, 10:30 AM
Thats all there is does the same but links to the top of the page:-

<td width="8%" onclick="navigate('#Top');">

// Used for pulldown boxes to jump to a specific bookmark
function JumpTo ( sOption ) {
navigate ( sOption);

khalidali63
02-06-2003, 10:41 AM
Since I do not have all of your code infront of me,i'll just say that for now comment
//navigate()

out and then put the his code in the jumpTo function


document.ifrm.document.location.href =sOption

your jumpTo function now should look like this

function jumpTo ( sOption ){
//navigate(Option)
document.ifrm.document.location.href =sOption

}

ashers
02-06-2003, 10:59 AM
Thanks

This works:-

function JumpTo ( sOption ) {
parent.frames[0].navigate ( sOption );