HELP! Page.RegisterStartupScript not working right in firefox

D

Dav

In my ASP.NET codebehind I have the following code to jump to a certain
section of the page:

---
Dim strAnchorScript As String = "<script language='javascript'>" & _
"window.location.hash='#" & strLink & "'</script>"

Page.RegisterStartupScript("anchorScript", strAnchorScript
---

In IE when it loads the page it jumps to a certain section of the page.
For firefox it just loads the page. But if I refresh the page in
firefox it jumps to the the section I want.

So, how do I get this to work in firefox (to use
Page.RegisterStartupScript and to jump to a certain place on the page)?
This seems like the easiest way to jump to a certian page.

Please post your answer here (no emails) and no flames.

Thanks for you help!
 
G

Guest

Hi,
I suspect there are some probematic characters in strLink.Try
escape(strLink) and see if it is working or not.

Thanks and Regards,
Manish Bafna.
MCP and MCTS.
 
M

Mark Rae

In my ASP.NET codebehind I have the following code to jump to a certain
section of the page:
Dim strAnchorScript As String = "<script language='javascript'>" & _
"window.location.hash='#" & strLink & "'</script>"

Page.RegisterStartupScript("anchorScript", strAnchorScript

Well, the first thing to do is to eliminate your outdated non
XHTML-compliant script declaration:

"<script language='javascript'>"

is deprecated in favour of:

"<script type='text/javascript'>"

I'm not saying that will definitely solve it but, when things work in IE and
not in other browsers, it's almost always because of IE's non-standard
behaviour.
In IE when it loads the page it jumps to a certain section of the page.
For firefox it just loads the page. But if I refresh the page in
firefox it jumps to the the section I want.

Second thing to do is to examine the source in IE and FireFox - what's
different...?
So, how do I get this to work in firefox (to use
Page.RegisterStartupScript and to jump to a certain place on the page)?
This seems like the easiest way to jump to a certian page.

Yes, it certainly should work. However, might it be that it doesn't work in
FireFox the first time because of script placement? I.e. is FireFox trying
to run the code too early, before the whole page has been completely built?
See here:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21622556.html
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top