Link to home
Start Free TrialLog in
Avatar of webressurs
webressursFlag for Norway

asked on

ClientScript.RegisterClientScriptBlock -redirect dont works in firefox?

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 :)
ASKER CERTIFIED SOLUTION
Avatar of Göran Andersson
Göran Andersson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
samtran0331, read the first sentence of the question.

Response.Redirect can only be used to do a redirect in the same frame.
Avatar of webressurs

ASKER

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 :)
Just what I needed!