sanjay Kumar
sanjay Kumar

Reputation: 140

how to get redirected to a page whose link is stored in a variable?

var f="http://www.google.com"; 'f' is a variable there is a link stored in f. Is there anyway to place a link which can redirect us to a link in variable f?

Upvotes: 0

Views: 79

Answers (2)

Faraz
Faraz

Reputation: 146

var f="http://www.google.com";

//redirect code<br>
location.href = f

Upvotes: 0

Sarfraz
Sarfraz

Reputation: 382826

Is there anyway to place a link which can redirect us to a link in variable f?

Use window.location Docs:

var f="http://www.google.com";
window.location = f;

Upvotes: 2

Related Questions