Razor code is server side and is sent to the client already rendered. Getting the client to write Razor code in javascript will not work.
Instead, you can just write your <a></a>
tag directly. You can use some server side variables though using razor. For example:
document.write('<a class="t-button" style="width: 200px; color: white; text-align: center" href="index/home?loggedin=@ViewBag.id" >Back</a>');
That way you can pick up your server side values and create the link as you require it.