Firefox and Javascript location problem

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
 
M

Martin Honnen

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?
 
J

John

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top