How to redirect if JavaScript and meta redirect are disabled?

687 views Asked by At

How to redirect if JavaScript and <meta redirect> are both disabled? Is there any way to redirect a page if both are disabled?

I found the useful questions How to redirect if javaScript is disabled? and redirect to another page if javascript is disabled which are redirecting using <meta redirect>, but if I disable meta redirect from e.g. the Firefox Web Developer extension then it will not redirect. Below is the image which shows how to disable JavaScript and meta redirects.

enter image description here

One more solution we have is that we can hide the html or body elements but anyone can use Firebug or other tool to make it visible, and which is not a trick now.

Do we have any option to work with <noscript> in this case or any server-side script (like PHP) to make it work?

1

There are 1 answers

0
Dan Horton On

Create a hidden field.

<asp:Hidden runat="server" ID="JSCheck" />

Then on page load, add the following script.

string sJSCheckValue = "1";
protected void Page_Load(object sender, EventArgs e)
{
    Page.ClientScript.RegisterStartupScript(this.GetType(), "jscheck", "document.getElementById(\"" + JSCheck.ClientID + "\").value = "+ sJSCheckValue +";", true);
}

on button press check if the value exists.

protected void btnLogin_Click(object sender, EventArgs e)
{
bool IsJavaScriptEnabled = JSCheck.value == sJSCheckValue;
//Redirect Here
}