工作,我有一個標記window.event JavaScript代碼無法在Firefox
<div id="uploadControl" class="fileUpload1">
<label for="uploadFile" id="labelId">Choose File</label>
<input class="upload" type="file" id="uploadFile" />
</div>
的JavaScript
window.onload = function() {
document.getElementById('uploadControl').onclick = function (event) {
// process the event only for the original source
if (window.event.srcElement.id === 'uploadControl') {
document.getElementById('labelId').click();
}
//prevent event propagation
window.event.cancelBubble = true;
};
}
我要在標籤火輸入文件單擊事件每當「上傳控制「div被點擊。 問題是....這在IE和Chrome,但在Firefox中我得到的消息
「類型錯誤:window.event是未定義」
好像火狐犯規支持window.event代碼。 我如何使它在Firefox上工作?請幫助
爲什麼你不使用'event(event){'? –
我發佈的答案你可以嘗試, –