document.getElementById('').va ... [英] document.getElementById('').va...

查看:104
本文介绍了document.getElementById('').va ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用Javascript代码获取用户名,它将在Internet Explorer中正常工作,但如果我使用firefox浏览器,则txtUsernName无法获取,是否有单独的firefox浏览器代码. ..

我在Google上学习,但没有得到答案,
我希望我能从这里得到答案.

var txtuser = document.getElementById(''<%= txtUserName.ClientID%>'').value;


谢谢与问候
亲爱的.

In my project I'' m using the Javascript code for getting the User name, it will work fine in Internet Explorer, but the txtUsernName is not getting if I use fire fox Browser, is there any separate code for firefox browser...

I serached in Google, but i didn''t get the answer,
I hope I vl get the answer from here..

var txtuser= document.getElementById(''<%= txtUserName.ClientID %>'').value;


Thanks & Regards
Honey.

推荐答案

可以尝试

You can try

var txtUsName = document.getElementById('<%= txtUserName.ClientID %>');
txtUsName.value = "User Name";



此行应写在您的HTML标记之后



this line should be written after your HTML Tags


1.我建议您尝试像这样分开它

1. I suggest you try separating it like this

var txtBox = document.getElementById('<%= txtUserName.ClientID %>');
txtBox.value = "Any value";



我发现这有时行得通,但不确定为什么,也不确定是否可以,但您可以尝试.

另外,我认为您应该开始使用jQuery,因为它已经根据用户浏览器使用了实现,因此,如果我们起诉jQuery,我们就不必担心浏览器的依赖性.

像jQuery一样的方法



I found this to work sometimes I am not sure why and not sure whether it will in your case but you can try.

Also, I think you should start using jQuery because it has use the implementation according to the users browser so we have to worry less about browser dependency COMPARATIVELY if we sue jQuery.

like in jQuery the methos like


(' #txtBox' span>).val(" );
('#txtBox').val("Any value");



可以在所有浏览器上使用.



will work on all browsers.


这篇关于document.getElementById('').va ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆