PDA

View Full Version : iframe events/javascript



jacobhebert
10-16-2008, 09:47 PM
Hello,

I am trying to solve an annoying problem I am having with frames on a real estate site I'm building. Basically, I have all my search results in a frame, and whenever a consumer clicks on something in the frame, it changes the page in the frame but leaves the main window scrolled down wherever they were on the main page, while the new page in the frame starts displaying the information above where they are looking without scrolling up manually.

So I'm wondering if I can set up a javascript function of some sort on the actual frame that will accomplish something like:

onload, or onreset, etc. (is there a command that will detect when the frame changes to a new page?) the main page will jump to a bookmark (#top)...

If anyone knows if this is remotely possible, please let me know!

HalaalPages
10-16-2008, 09:58 PM
the problem lies on the other end of the process...the one you have no control over. I am assuming you are using an independent search party like FreeFind or something like that?

If however, you have control of the linkage within the iFrames, set the target of each link to _parent and that should open up the links in the current window which hosts the iFrame.

jacobhebert
10-16-2008, 10:08 PM
I don't have control over what i'm using at the moment, which is just the local MLS's idx, but I will when I have a custom idx...

However, the reason I have a frame is so that the results load in the body my site, so they still have access to all of my regular website navigation and branding. So even when I can manipulate the links within the frame, I will want to keep it in there, even if i have to settle for dealing with them scrolling around!

Thanks for the response though, I have considered just opening the original frame in a new window to avoid this, but I really like the way everything looks and works with frames aside from this one problem!

HalaalPages
10-16-2008, 10:29 PM
could u post a link to one of ur pages?

jacobhebert
10-16-2008, 11:06 PM
Sure, this is a page where consumers can search by subdivision, and all of the text below and including "Subdivision Search" is in the frame, and when you click on a subdivision name, it lists the properties for sale.

http://franketeam.net/conroesubdivisions.html

Really if I could just get the code for a more simple javascript function like onclick, with the same result, I could play around with it and possibly find something that works...

HalaalPages
10-17-2008, 01:07 AM
If you have access to all the pages within the iFrame, what you could do is add a target='_parent' tag to each of the links. Man, would that be arduous. But if that's the outcome you seek, then that's the best I can think of. I see why you need a script because that's a LOT of pages.

By the way, nice site. Just one thing though, if I may, about the scrolling of the iFrame, it does not look to me that it's really needed. I would widen the Frame a bit and set the scrollbars option to never. I think it would look a lot smoother.

Collectors-info
10-17-2008, 09:41 AM
Hi, its not much help, but if you can get a script to reload or refresh the parent page when choosing a link to have another page open in the iframe it will reload with the original url that was set for the iframe & will end up going back to the beginning.
But there might be someone clever & solve this.????

Good luck.

davidundalicia
10-17-2008, 10:10 AM
You dont need a script to accomplish this.

At the moment you have to scroll the main page to see the complete contents of the Iframe...............so

decrease the length of the main page, that includes the Iframe itself, so that it fits on the screen.
This will lose the scollbar on the main page.

Add the scrollbar to the Iframe.

Now, clients can still scroll down

but when they click on any link in the Iframe the new window will open at the top of the Iframe.

The bonus is that the main menu bar and the header stays in view and gives the appearance of a fixed background.

You can see this working here (http://bluevodamembersclub.com/welcome/forum_rooms.php)

Change the main page only and your 60 odd pages will not need changing.