PDA

View Full Version : Help with Javascript and Frames



Tifoso
07-02-2008, 02:41 AM
Hello, Im quite new to html and javascript and am in the process of building a page, however im stuck on getting it to work how I need. The page consists of two horizontal frames(rows). Within the top frame is a javascript that uses large images which are resized within the code to thumbnail size and on mouseover the full sized image is shown below it. For various reasons I need it this way rather than creating actual thumbnails. What I would like is that onmouse over of the smaller image in the top frame, the larger image is shown in the second frame(the bottom one). Im unsure how to acheive this and hope someone could please help point me in the right direction..any help is much appreciated. Please excuse any lack of clarity or information in my query. Many Thanks

magicyte
07-02-2008, 02:53 AM
Very simple. First of all, I have a question. What is the name of your bottom frame? It depends. try this code in the script section:

parent.whateveryourbottomframenameis.document.getElementById("whatevertheheckyourimageidis").src="whatevertheheckyourimgsrcis.extension". hope i help.

-magicyte

Tifoso
07-02-2008, 04:31 AM
Hello magicyte and thank you for your reply. In the interest of simplicity the name of my bottom frame is "bottom.html". Also my image does not have an i.d...would I be wrong in assuming this is the way to give it one "<img name=flw src="flower.jpg">? Needless to say I couldnt get the code to work...obviously due to things Im doing...or not doing correctly...however I really appreciate your help

Tifoso
07-02-2008, 04:40 AM
..yes i would be wrong...id="flw" seeing as thats what the code is referring to... :o/ ?

Tifoso
07-03-2008, 06:25 AM
Well I just thought Id follow up by saying I've finally achieved what I set out to do in regards to my page. Took alot of reading and researching and a whole lot of trial and error. Although the coding and method I used was a bit different to the way magicyte suggested, his suggestion was definately what set me off in the right direction and path to getting this to work finally. So again magicyte thank you for your help, it is very much appreciated. Take care, Sincerly Tifoso

codeexploiter
07-03-2008, 06:27 AM
if you can share the code or a link everyone can have a look at it to know your method.

Tifoso
07-04-2008, 04:30 AM
Well my site isnt online just yet so Ill try and explain it as best I can. I placed the Javascript code in the second frame(the bottom one) and in the first frame(top) I placed the image references and made them onmouseover point to the function in the second frame.
<img src="chart1.gif"
onmouseover="parent.lower.popImg(true, this);"
onmouseout="parent.lower.popImg((false);"
Hope that makes sense

magicyte
07-05-2008, 01:51 AM
I am going to code a little bit here so that I type less. Hope you understand it:
try
{
Well, basically what you are wanting to do is this: you are wanting to have someone put thier mouse over an image which will then widen. In the bottom frame a large form of the image will show up. Am I correct?
if(correct)
{
Here is an example code for the image-over thing:


<img src="some_img.jpg" onmouseover="this.style.width=200;this.style.height=200;parent.name_of_frame.document.getElementById('name_of_img').src=this.src;" onmouseout="this.style.width=150;this.style.height=150;parent.name_of_frame.document.getElementById('name_of_img').src=differing_source.jpg">

}
else
{
I am sorry that I couldn't help you. Please try the catch() statement.
}
}
catch(e)
{
Well, if I am not, I guess you will have to reply once more for complete clarification.
}

-magicyte

Tifoso
07-08-2008, 02:54 AM
Hello magicyte. You are correct and your code does make sense and works. I was using a code that I copied from somewhere which took a bit of playing with but I managed to get working how I needed, however the code you supplied me with is definately useful to me and extremely good to know. Again I really appreciate your time and help and hope others can use this information to their benifit also. Thank you

magicyte
07-08-2008, 05:05 PM
You are very welcome. 'Tis a pleasure to help you!

-magicyte