Firefox/Chrome does not support attributes of attributes. Add ("defaultvalue") in front-end JS reading background

Source: Internet
Author: User

The followingCodeIt works normally in IE but not in Firefox/chrome. Why?

C #:
This. textboxemailaccount. Attributes. Add ("defaultvalue", this. useraccounttextboxdefaultvalue );

JS:
Function focususeraccountbox (OBJ ){
If (obj. value = obj. defaultvalue ){
OBJ. value = "";
}
OBJ. style. color = "black ";
}
Function bluruseraccountbox (OBJ ){
If (obj. value = ""){
OBJ. value = obj. defaultvalue;
OBJ. style. color = "gray ";
}
}


The method for retrieving sessions in JS is not supported in Firefox/chrome!
<SCRIPT type = "text/JavaScript">
If (document. getelementbyid ("mainiframe ")! = NULL)
{
VaR url = '<% = session ["currentpageurl"] %> ';
Alert (URL)
VaR menulevel = '<% = session ["currentpagemenulevel"] %> ';
If (URL! = "" & URL! = NULL)
{
Document. getelementbyid ("mainiframe"). src = '<% = session ["currentpageurl"] %> ';
}
If (menulevel! = "" & Menulevel! = NULL ){
Setnavigator (menulevel. Replace ("$ ","&"));
}
}
</SCRIPT>
The following JavaScript code cannot be written in Firefox/chrome!
Function document. onkeydown (){
If (window. event. keycode = 13 & window. Event ){
Document. getelementbyid ("qbuttonlogin"). Click ();
}
}

Alternative solution:
<SCRIPT type = "text/JavaScript">
<! --

If (document. addeventlistener) {// if it is Firefox
Document. addeventlistener ("keypress", firefoxhandler, true );
} Else {
Document. attachevent ("onkeypress", iehandler );
}

Function firefoxhandler (EVT ){
// Alert ("Firefox ");
If (EVT. keycode = 13 ){
Validatelogon ();
}
}

Function iehandler (EVT ){
// Alert ("ie ");
If (EVT. keycode = 13 ){
Validatelogon ();
}
}

// -->
</SCRIPT>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.