Javascript 韩元';不要在PDF或缩放中更改页面

Javascript 韩元';不要在PDF或缩放中更改页面,javascript,internet-explorer,pdf,microsoft-edge,Javascript,Internet Explorer,Pdf,Microsoft Edge,我使用的是Windows 10,我的桌面上有一个名为pdf.html的文件 pdf.html的内容是 <!DOCTYPE html> <html> <head> <script type="text/javascript"> function goAndZoom(pageNum,zoom) { var pdf = document.getElementById('pdf'); pdf.data = pdf.data+'#page=

我使用的是Windows 10,我的桌面上有一个名为
pdf.html
的文件

pdf.html
的内容是

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

function goAndZoom(pageNum,zoom)
{
    var pdf = document.getElementById('pdf');
    pdf.data = pdf.data+'#page='+pageNum+'&zoom='+zoom;
    document.body.removeChild(pdf);
    document.body.appendChild(pdf);
}
</script>
</head>
<body>
<button onclick="goAndZoom(4,300);">Go to Page 4 and zoom 300%</button>
<object id="pdf" data="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf" width="100%" height="700px" type="application/pdf">
<param name="zoom" value="100" />
</object>

</body>
</html>

函数goAndZoom(pageNum,zoom)
{
var pdf=document.getElementById('pdf');
pdf.data=pdf.data+'#page='+pageNum+'&zoom='+zoom;
document.body.removeChild(pdf);
document.body.appendChild(pdf);
}
转到第4页,缩放300%
我用Chrome打开这个文件。当我按下“转到第4页并缩放300%”按钮时,嵌入的pdf将转到第4页并缩放300%。当我在Edge browser中重复这两个操作时,pdf将保持在第1页,而不会改变缩放。我与其他人共享了这个
pdf.html
文件,他们在使用IE 11时报告了相同的问题


如何让
goAndZoom()
函数转到PDF中的页面并放大IE和Edge?

Internet Explorer在处理html对象时有奇怪的行为。尝试使用相同的属性创建新对象

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

function goAndZoom(pageNum,zoom)
{
    var pdf = document.getElementById('pdf');
    var newPdf = document.createElement("object");
    newPdf.type = "application/pdf";
    newPdf.height = pdf.height;
    newPdf.width = pdf.width;
    newPdf.id = pdf.id;
    newPdf.data = pdf.data+'#page='+pageNum+'&zoom='+zoom;
    document.body.removeChild(pdf);
    document.body.appendChild(newPdf);
}
</script>
</head>
<body>
<button onclick="goAndZoom(4,300);">Go to Page 4 and zoom 300%</button>
<object id="pdf" data="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf" width="100%" height="700px" type="application/pdf">
<param name="zoom" value="100" />
</object>

</body>
</html>

函数goAndZoom(pageNum,zoom)
{
var pdf=document.getElementById('pdf');
var newPdf=document.createElement(“对象”);
newPdf.type=“应用程序/pdf”;
newPdf.height=pdf.height;
newPdf.width=pdf.width;
newPdf.id=pdf.id;
newPdf.data=pdf.data+'#page='+pageNum+'&zoom='+zoom;
document.body.removeChild(pdf);
document.body.appendChild(newPdf);
}
转到第4页,缩放300%

截至2016年4月27日,还没有解决方案

我知道我来晚了,但这里有答案

在IE中,您(可能)实际上使用Adobe Reader通过阅读器插件显示PDF。如果PDF尚未在查看器中打开,则PDF open参数可以工作,但如果只是将其附加到同一源中,则不能工作。读取器知道文件已打开,并忽略打开的参数。您需要先将data属性设置为nothing,然后返回带有参数的URL以使其正常工作


对于Edge。。。放弃。它不会解释打开的参数

这仍然不起作用……MS Edge似乎不尊重页面加载或通过javascript操作时的哈希标记和其他查询字符串参数,甚至不删除代码方面,即在更改设置后不尊重URL中的哈希标记。