[英]javascript works on IE but doesnt on firefox and chrome
這段javascript代碼僅適用於IE為什么以及如何使其在firefox和chrome上運行。 提前致謝。
使用Javascript
function uploadFileChange() {
if (document.getElementById('textbox1').value != document.getElementById("FileUpload1").value) {
document.getElementById('textbox1').value = document.getElementById("FileUpload1").value;
}
return false;
}
HTML / asp.net
<div class="fileinputs">
<!-- Upload file invisivel-->
<asp:FileUpload ID="FileUpload1" ClientIDMode="Static" class="file" runat="server"
onpropertychange="uploadFileChange();" />
<!-- button e textbox falsas para poder dar syles ao button-->
<div class="fakefile">
<asp:TextBox ID="textbox1" CssClass="textbox" ClientIDMode="Static" runat="server"
Width="31%" ReadOnly="true" />
<asp:Button ID="FileChooserButton1" CssClass="btnSubmit" runat="server" Text="Procurar..."
ForeColor="White" />
<asp:Button ID="FileChooserButton2" CssClass="btnSubmit" Text="Apagar" ForeColor="White"
OnClientClick="clear();" runat="server" />
</div>
</div>
解決
onpropertychange事件僅限IE,因此不會在其他瀏覽器中觸發,請參閱http://help.dottoro.com/ljufknus.php 。
請使用onchange事件而不是http://forums.asp.net/t/1138684.aspx/1
使用警報。 並嘗試提醒兩個值..u將會知道原因..很可能其他瀏覽器返回undefined ...更好地使用警報和調試值。 它可能編碼錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.