//Disable/Enable Javascript from code(Registry):
public static void EnableDisableJavaScript(bool enable)
{
//get the registry key for your local system
RegistryKey regKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Main", true);
if (regKey != null)
{
try
{
//if you want to disable script debugging
if (enable == false)
{
//set REG_SEZ for Disable Script Debugger(Internet Explorer) to yes
regKey.SetValue("DisableScriptDebuggerIE", "yes");
//set REG_SEZ for Disable Script Debugger(Other) to yes
regKey.SetValue("Disable Script Debugger", "yes");
}
else //if you want to enable script debugging
{
//set REG_SEZ for Disable Script Debugger(Internet Explorer) to no
regKey.SetValue("DisableScriptDebuggerIE", "no");
//set REG_SEZ for Disable Script Debugger(Other) to no
regKey.SetValue("Disable Script Debugger", "no");
}
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message, null);
}
}
}
The journey of thousand miles starts with single step.
You're aware that the registry settings are set in the server where the code is executing, not the client machine? Hence all this will do is stop you debugging effectively. As soon as your site goes live, this won't have any effect.
sagar11188
Member
142 Points
41 Posts
Dont allow the user to enable javascript debugging.
Jan 31, 2011 09:38 AM|LINK
If you want user to not allow for enabling javascript debugging ,you can try this.I googled for this and I found this.Hope it help.
Include the Namespace: using Microsoft.Win32;
//Click of btnDisableJavascript
protected void btnDisableJavascript_Click(object sender, EventArgs e)
{
bool enable = false;
if (btnDisableJavascript.Text == "Disable Javascript")
{
enable = false;
btnDisableJavascript.Text="Enable Javascript";
}
else
{
enable = true;
btnDisableJavascript.Text="Disable Javascript";
}
EnableDisableJavaScript(enable);
}
//Disable/Enable Javascript from code(Registry):
public static void EnableDisableJavaScript(bool enable)
{
//get the registry key for your local system
RegistryKey regKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Internet Explorer\\Main", true);
if (regKey != null)
{
try
{
//if you want to disable script debugging
if (enable == false)
{
//set REG_SEZ for Disable Script Debugger(Internet Explorer) to yes
regKey.SetValue("DisableScriptDebuggerIE", "yes");
//set REG_SEZ for Disable Script Debugger(Other) to yes
regKey.SetValue("Disable Script Debugger", "yes");
}
else //if you want to enable script debugging
{
//set REG_SEZ for Disable Script Debugger(Internet Explorer) to no
regKey.SetValue("DisableScriptDebuggerIE", "no");
//set REG_SEZ for Disable Script Debugger(Other) to no
regKey.SetValue("Disable Script Debugger", "no");
}
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message, null);
}
}
}
Please mark as'ANSWER' if any post helps.
keych
Member
4 Points
2 Posts
Re: Dont allow the user to enable javascript debugging.
Feb 27, 2011 07:32 AM|LINK