admin管理员组文章数量:1434916
I'm using viewer.js (/) to view pdf's on a website, and I want to pull the attribute "title" from the iframe code to title the document.
At the moment the code is as follows
<iframe id="viewer" src = "/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe>
and I want to be able to do this
<iframe id="viewer" src = "/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen title="Document Title"></iframe>
I know the bit of code in the js file I need to edit is as follows
document.getElementById("documentName").innerHTML=document.title
and I tried the following but with no luck
document.getElementById("documentName").innerHTML=document.attr('title')
I'm just not sure how to get the attribute.
The full source code for viewer.js can be viewed at .js
I'm using viewer.js (http://viewerjs/) to view pdf's on a website, and I want to pull the attribute "title" from the iframe code to title the document.
At the moment the code is as follows
<iframe id="viewer" src = "/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe>
and I want to be able to do this
<iframe id="viewer" src = "/ViewerJS/#../demo/ohm2013.odp" width='400' height='300' allowfullscreen webkitallowfullscreen title="Document Title"></iframe>
I know the bit of code in the js file I need to edit is as follows
document.getElementById("documentName").innerHTML=document.title
and I tried the following but with no luck
document.getElementById("documentName").innerHTML=document.attr('title')
I'm just not sure how to get the attribute.
The full source code for viewer.js can be viewed at http://viewerjs/ViewerJS/viewer.js
Share Improve this question edited Jun 25, 2014 at 9:51 dpDesignz asked Jun 25, 2014 at 9:15 dpDesignzdpDesignz 1,95910 gold badges35 silver badges72 bronze badges2 Answers
Reset to default 7It is possible to pass the title
parameter like this:
<iframe src="/ViewerJS/?title=My PDF Title#../demo/ohm2013.odp"></iframe>
Just notice that it must be placed before the document's URL.
Worked out how to do it, it just needed to be as follows
document.getElementById("documentName").innerHTML=window.frameElement.title
本文标签: javascriptViewerJS File Name from Title AttributeStack Overflow
版权声明:本文标题:javascript - Viewer.JS File Name from Title Attribute - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745632694a2667369.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论