Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';使用javascript设置HTML对象元素的数据属性_Javascript_Html - Fatal编程技术网

Can';使用javascript设置HTML对象元素的数据属性

Can';使用javascript设置HTML对象元素的数据属性,javascript,html,Javascript,Html,以下内容适用于当前Firefox(PDF加载),但不适用于当前IE(页面为空白)。有什么建议吗 <head> <script type="text/javascript"> function startup() { var bubba = document.getElementById('bubba'); bubba.data = 'http://server.qa/test.pdf';

以下内容适用于当前Firefox(PDF加载),但不适用于当前IE(页面为空白)。有什么建议吗

<head>
    <script type="text/javascript">
        function startup() {
            var bubba = document.getElementById('bubba');
            bubba.data = 'http://server.qa/test.pdf';
        }
    </script>
</head>
<body onload="startup();">
    <object id="bubba" type="application/pdf" width="80%" height="800">
      No PDF reader installed
    </object>
</body>

函数启动(){
var bubba=document.getElementById('bubba');
布巴数据中心http://server.qa/test.pdf';
}
没有安装PDF阅读器

您将无法像那样显示PDF。IE和Foreox之间包含插件的语法不同

我建议使用
而不是
,并使用JavaScript设置iframe的
src
属性。这应该调用浏览器中安装的PDF插件,如果没有,则下载PDF