?
Solved

ClientScript.RegisterClientScriptBlock -redirect dont works in firefox?

Posted on 2007-11-18
5
Medium Priority
?
1,866 Views
Last Modified: 2012-06-27
I have a frames based page, and need to make a redirect out of the frameset. I read that this could be done with javascript "top.location.href". It works fine in IE 7.0, but when testing it in Firefox it dont redirect at all (the browser has javascript enabled).

------------------------------------------------------------
This works in IE 7, but not in Firefox:
------------------------------------------------------------
string redirectUrl = "/view.aspx?id=" + Content.Id + "&newId=" + Content.Id;
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Redirect", "top.location.href('" + redirectUrl + "');", true);

------------------------------------------------------------
I tried this also, but it only works in IE 7:
------------------------------------------------------------
string redirectUrl = "/view.aspx?id=" + Content.Id + "&newId=" + Content.Id;
Response.Write("<script language='javascript'>top.location.href('" + redirectUrl + "');</script>");


Why does it not work in Firefox?? Thanks :)
0
Comment
Question by:webressurs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 2000 total points
ID: 20309204
href is a property, not a method.
string redirectUrl = "/view.aspx?id=" + Content.Id + "&newId=" + Content.Id;
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "Redirect", "top.location.href='" + redirectUrl + "';", true);

Open in new window

0
 
LVL 37

Expert Comment

by:samtran0331
ID: 20309360
since you're trying to redirect the page after the code executes, there's really no need to use javascript, you can redirect from the codebehind with:

Response.Redirect("view.aspx?id=" + Content.Id + "&newId=" + Content.Id);

instead of RegisterClientScriptBlock
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20309804
samtran0331, read the first sentence of the question.

Response.Redirect can only be used to do a redirect in the same frame.
0
 
LVL 1

Author Comment

by:webressurs
ID: 20310434
Hi! As GreenGhost say Response.Redirect can only be used to do a redirect in the same frame. Thats why I need to use a javascript fro doing this. Thank you GreenGhost , it worked perfect in IE and Firefox :)
0
 
LVL 1

Author Closing Comment

by:webressurs
ID: 31409835
Just what I needed!
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question