Named anchor jump problem

He has: 3 posts

Joined: Aug 2006

Hi all,

First post here, so the usual new user apologies-in-advance apply.

There's an odd problem I'm experiencing with Firefox (1.5.x for Mac and Windows) and Safari (any version, I think, for Mac). Rather than exerting an inordinate amount of effort writing down what the problem is, I'll just show you:

  1. Be so kind as to visit http://www.bettertrolley.com/index_sep06.html in Firefox or Safari.
  2. Here's the site. You'll be presented with a transit map on the left, and a column information on the right. Click on any station (that is, any of the items in black type) on the transit map.
  3. What's supposed to happen is the area under "Station Information" changes to what station you clicked.

Now -- here's the problem. If your viewport was set to something 1024 x 768-ish or smaller, you'll have noticed it already: the page "jumps" down.

I can explain partly why this happens, I think: The station information list is a big long page (http://www.bettertrolley.com/maps/stations.xml) inside of an iframe with lots of named anchors (#1, #2, #3 ... #53). So what the Flash module does is get a URL like "stations.xml#25" with the target being the iframe. The browser tries to scroll the parent window along with the child (iframe) window when the link is clicked to go the named anchor.

Whew.

So how might I solve this? How can I get the iframe to jump to the right location, but not have the parent window try to jump there too? (Oddly enough, IE 6 for Windows does this properly. I know. I was as stunned as you are.)

Thanks in advance for your help. Any suggestions will be greatly appreciated.

(edit: I had a typo in one of my URLs.)

Busy's picture

He has: 6,151 posts

Joined: May 2001

I can't see it because it's done in flash, but can you align it to the center or to a centered anchor?

He has: 3 posts

Joined: Aug 2006

For each of the stations in Flash, the code looks something like:

[="Courier New"]on (press) {
getURL ("/maps/stations.xml#25","infoframe");
}[/]

Where "infoframe" is the name of the iframe containing that XML file I referenced in my first post. I'm not sure what you mean by "aligning it to the center" ... aligning what to the center? Moreover, I'm not even sure what a "centered anchor" is.

Apologies for making your life difficult.

Busy's picture

He has: 6,151 posts

Joined: May 2001

Say the map is horziontal, going from #1 (far left) to #30 (far right), instead of calling just the stations.xml file as default, can you set it like stations.xml#15 as default as 15 would be the center anchor.

Sorry if is confusing you, is hard not being able to see the problem but I hate flash with a passion and would rather play in traffic than have it

He has: 3 posts

Joined: Aug 2006

I think I understand. I set up the XSL to format the XML list of stations horizontally (instead of vertically) using a simple table structure. Unfortunately, it still jumped in the same way ... which of course is still the problem.

New approach. I tried sending a javascript instruction to the iframe instead:

[INDENT][="Courier New"]window.location('#25'); [/][/INDENT]

And it looks like it worked for just a flicker ... but then it replaced the iframe's contents with a page that just consisted of the text "#25" and returned an error in the javascript console. I think I'm on the right track here ... but what am I doing wrong that causes the iframe's contents to be replaced.

As always ... any help is appreciated. Many thanks!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.