我不知道,但我可能失去了一些東西,我已經試過了幾thigns但他們都最終獲得相同的結果,我要開始拉我的頭髮的javascript「的document.getElementById未定義」
<script type="text/javascript">
function set_size() {
// Get users Screen Res
var screen_height = screen.height;
var attribute = "height";
var element = "pdfFile";
// Take say 200px off the res to accumulate the browser screen useage
var object_height = screen_height - 200;
// Write to the height attribute
document.getElementById[element].getAttribute[attribute].value = object_height;
document.getElementById['jsoutput'].innerhtml = object_height;
}
</script>
<div class="Contact_list">
<a name="contacts"><object id="pdfFile" data="files/contacts/pdf/contacts.pdf" type="application/pdf" width="100%" height="600" style="border: 1px solid;"></object></a>
<span id="jsoutput"></span>
</div>
<script type="text/javascript">
set_size();
</script>
[12:13:28.050]的document.getElementById [元件]是未定義@http://localhost/* */index.php頁面=接觸#聯繫人:57
「document.getElementById ['jsoutput']。innerhtml = object_height;」是否需要輸出設置對象的大小,我正在使用它進行調試。我將應用這些其他更改:) – cyclobs
「document.getElementById(element).style.height = object_height;」 不起作用:我得到一個CSS錯誤「[12:47:25.390]解析'height'的值時出錯。 – cyclobs
如果你有正確的地方所有的代碼,它似乎在這裏工作得很好。在這個jsfiddle中看到它:http://jsfiddle.net/jfriend00/SeLry/ – jfriend00