标题属性中的 Viewer.JS 文件名

dpD*_*gnz 3 javascript iframe jquery attr

我正在使用 viewer.js ( http://viewerjs.org/ ) 在网站上查看 pdf,我想从 iframe 代码中提取属性“title”来为文档添加标题。

目前代码如下

<iframe id="viewer" src = "/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe>

我希望能够做到这一点

<iframe id="viewer" src = "/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen title="Document Title"></iframe>

我知道我需要编辑的js文件中的代码如下

document.getElementById("documentName").innerHTML=document.title
Run Code Online (Sandbox Code Playgroud)

我尝试了以下但没有运气

document.getElementById("documentName").innerHTML=document.attr('title')
Run Code Online (Sandbox Code Playgroud)

我只是不确定如何获得该属性。

查看器的完整源代码可以在http://viewerjs.org/ViewerJS/viewer.js查看

Car*_*eda 5

可以title像这样传递参数:

<iframe src="/ViewerJS/?title=My PDF Title#../demo/ohm2013.odp"></iframe>
Run Code Online (Sandbox Code Playgroud)

请注意,它必须放在文档的 URL之前