dazzling kumar
dazzling kumar

Reputation: 604

window.setTimeout('window.location="http://www.example.com"; ', 2000); in code behind

i want to make this script in code behind because to change the url dynamically

<script language="javascript" type="text/javascript">
 window.setTimeout('window.location="http://www.example.com"; ', 2000);
 </script>

and i have tried this but not working

 ClientScript.RegisterStartupScript(this, GetType(), "closePage", "window.setTimeout('window.location='http://www.example.com';',5000)", true);

can any one tell how to do this

Upvotes: 1

Views: 343

Answers (1)

Dgan
Dgan

Reputation: 10285

try this

100% working and Tested

You Need to Use @ for Escape Sequence and Some Changes as below

ScriptManager.RegisterStartupScript(this, this.GetType(),Guid.NewGuid().ToString(), @"window.setTimeout('window.location=\'http://www.example.com\',5000');", true);

Upvotes: 1

Related Questions