Forum Moderators: open

Message Too Old, No Replies

OnClick & I-frames

         

rico

2:38 am on Jan 14, 2004 (gmt 0)

10+ Year Member



Hello, i made a post below, maybe this will grab you more i could have been asking wrong?

Basically on my site i have a navigation image map, and 3 i-frames. [menu] [main big] [extras].

What im trying to accomplish is OnClicking the menu say "Links" it will load a page in iframe1 and iframe2 (different pages). the 3rd is fine to not change. I appreciate you taking time and im not very great at javascript so basic instructions would be good, although im not a tard either :)

jatar_k

2:42 am on Jan 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld rico,

code here
[webmasterworld.com...]

I was just looking at that other thread rico, funny you should repost at this very moment. I will admit my javascript is not 100% but could you call a function that changed the 2 frames maybe? I figure you could pass the function the 2 pages that are to be loaded into the frames and the function could switch them for you.

make any sense?

rico

2:46 am on Jan 14, 2004 (gmt 0)

10+ Year Member



Actually im confused, hehe that went straight to my other post, and when i tried that code (which i couldnt get to work, perhaps i was doing something wrong?) it kept saying errors and "Expected }" or something.. kinda like this guy is saying

[webmasterworld.com...]

basically same errors.

jatar_k

2:53 am on Jan 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I was placing the link there for reference if people were wondering what previous post you were referring to. ;)

it kept saying errors and "Expected }" or something

those are syntax errors (essentially spelling mistakes), if you fix those then you get an idea of how the script is actually behaving.

rico

2:56 am on Jan 14, 2004 (gmt 0)

10+ Year Member



I dont see any spelling errors, unless im typing in the wrong code? Like i said im not great at all with java script, i can like copy and paste. As for functions etc.. im kinda like?

i dunno what to put though, if it helps thoguh my left iframe is "1" and my middle is "2"...

jatar_k

3:19 am on Jan 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



alright I did some base line testing to see if I could get it to work.

I started with your code. In your example you have the javascript in the wrong file from what I worked out. I used a 1st file called frametest.html all it has in it is this

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF" scroll="no">
<div style="position: absolute; top:235; left:128">
<iframe FRAMEBORDER="0" BORDER=0 marginwidth=0 marginheight=0 hspace=0 vspace=0 width=124 height=320 src="1.html" name=1 allowTransparency scrolling=auto style="FILTER: chroma (color=40FF40)"></iframe>
</div>
<div style="position: absolute; top:235; left:267">
<iframe FRAMEBORDER="0" BORDER=0 marginwidth=0 marginheight=0 hspace=0 vspace=0 width=486 height=320 src="2.html" name=2 allowTransparency scrolling=auto style="FILTER: chroma (color=40FF40)"></iframe>
</div>
<div style="position: absolute; top:235; left:767">
<iframe FRAMEBORDER="0" BORDER=0 marginwidth=0 marginheight=0 hspace=0 vspace=0 width=124 height=320 src="3.html" name=3 allowTransparency scrolling=auto style="FILTER: chroma (color=40FF40)"></iframe>
</div>
</BODY>
</HTML>

which is your frame code. I don't have the images or files so there are all kinds of 404's. The only file I created was 3.html which would be where your menu is and it has this

<HTML>
<HEAD>
<TITLE>some title</TITLE>
<script>
function twoFrameChange(left,middle){
parent.frames[0].location.href = left;
parent.frames[1].location.href = middle;
}
</script>
</HEAD>
<BODY bgcolor="#FFFFFF" scroll="no">
<p><A HREF="javascript:twoFrameChange('itsover.html','getup.html');">click it</a>
</BODY>
</HTML>

so it now has a working function in the head portion. Part of the problem is you used numbers for your frame name and that is confusing it. I accessed the via the frames array. Your 1 frame is the first on the page so I used

parent.frames[0].location.href = left;

this means in the parent page (because the frame needs to access the frames array of the top level page) change the location of the first frame to the value of the variable 'left' which is 'itsover.html'. All arrays start with 0 being the first element.

make any sense?

rico

3:49 am on Jan 14, 2004 (gmt 0)

10+ Year Member



I still dont quite understand how its working, but im really tired.. The important thing is IT WORKED! I had to do a few adjustments (like i said its off the image map so it was liek HREF=javascript:functionname('site','site');"> but yeah the important thing is i have it working. thank you SO much! i've been working at this for awhile. GREATLY appreciated you have no idea! thanks again!

jatar_k

8:21 am on Jan 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



take a look at tedster's response here too
[webmasterworld.com...]

BillPosters

10:07 am on Jan 14, 2004 (gmt 0)



Part of the problem is you used numbers for your frame name and that is confusing it.

It's also disallowed in HTML4 spec so should be avoided.

[w3.org...]

Something to bear in mind if you want to avoid creating other potential problems.