javascript - Viewer.JS File Name from Title Attribute - Stack Overflow

I'm using viewer.js () to view pdf's on a website, and I want to pull the attribute "ti

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 badges
Add a ment  | 

2 Answers 2

Reset to default 7

It 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745632695a4637204.html

相关推荐

  • javascript - Viewer.JS File Name from Title Attribute - Stack Overflow

    I'm using viewer.js () to view pdf's on a website, and I want to pull the attribute "ti

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信