Firefox and Javascript location problem

  • Thread starter Thread starter John
  • Start date Start date
J

John

I've been working on making my ASP.NET web apps compatible with Firefox (the
uplevel configs for web.config are a real help).

However, one really weird thing is a GotoAnchor() function I have (server
side), which injects javascript along the lines of:

location = '#buttons';

I use this so that, following postback, I can just back down to the relevant
part of the page.

It works fine in IE, but not in Firefox! Furthermore, I seem to loose other
Javascript injected following it (it's not simply malfunctioning, it's not
rendered by .NET!).

Any ideas why this is happening? Maybe a second postpack?

I can work around it by only emitting the javascript with IE - it's not the
end of the world. But a way to get similar functionality on Firefox would be
great.

Thanks,

John
 
John wrote:

However, one really weird thing is a GotoAnchor() function I have (server
side), which injects javascript along the lines of:

location = '#buttons';

Try whether
window.location.hash = '#buttons';
works better.
It works fine in IE, but not in Firefox! Furthermore, I seem to loose other
Javascript injected following it (it's not simply malfunctioning, it's not
rendered by .NET!).

Any ideas why this is happening?

What does the Firefox JavaScript console show? Any error messages?
 
Great, thanks! 'window.location.hash' solves the problem.

My original command must have been causing Firefox to reload the page a
second time following postback - there wern't any errors in the page, just a
lack of injected javascript!

I've now got full Firefox functionality (don't try saying that after a few
beers).

John
 
Back
Top