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