如何使用Asp.net禁用Google Chrome的"Chrome PDF Viewer"

hmk*_*hmk 6 asp.net google-chrome google-chrome-extension c#-4.0

由于一些不可避免的原因,我需要禁用Google Chrome的"Chrome PDF Viewer"并启用adob PDF查看器.我想从C#.net和asp.net Code做到这一点.我知道这是不可能直接的,因为它与客户端计算机上的更改设置有关但我准备要求用户的许可,如果他/她想要禁用默认查看器.

这项工作背后的原因是,由于Chrome的默认阅读器,我在iTextSharp中创建的所有PDF在Google Chrome中都无法正常运行.并非所有用户都可以手动查找和禁用插件,因此我希望它可以通过代码来完成.我需要知道我们如何禁用默认的PDF查看器.在此之后我的问题将自动解决.请给我任何关于代码的建议

小智 1

谷歌浏览器插件不会改变编程方式,所以只是像弹出消息一样通知客户端

<script type="text/javascript">
function CheckPlugin()
{
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
function findPlugin(ext) {
var thisExt, findExt;
for (var n = 0; n < navigator.plugins.length; n++) {
//alert("n value"+ navigator.plugins.length);
for (var m = 0; m < navigator.plugins[n].length; m++) {
//alert("m length:"+navigator.plugins[n].length);
thisExt = navigator.plugins[n][m].description.toLowerCase();
// alert("this exten"+thisExt);
findExt = thisExt.substring(0, thisExt.indexOf(" "));
//alert("findexes"+findExt);
if (findExt == ext)
return (true);
}
}
return (false);
}

if (is_chrome ==true) {
//alert("chrome browser");
if (findPlugin("acrobat")) {
//alert("Adobe Acrobat pdf viewer");
return true;
}
else {

alert("please disable the chrome pdf viewer and enable the Adobe Acrobat PDF viewer \n Please follow the steps:\n 1.Open the new tab 'chrome://plugins/' type the Address. \n 2. Click the Enable link in 'Adobe Acrobat' field. \n 3. click the Disable link in 'Chrome PDF Viewer'. \n 4. Close the tab and you can open the PDf files in chrome browser.");
return false;
}
}
else {
//alert("not chrome");
}
}

</script>
Run Code Online (Sandbox Code Playgroud)

在超链接中这样写

<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/PDFFiles/AGENCY PROFILE APP.pdf" onclick="return CheckPlugin();">Agency profile app</asp:HyperLink>
Run Code Online (Sandbox Code Playgroud)

我认为这更有帮助。