lang Example JavaScript (JS): HTML DOM Objects – Button Object – lang Example JavaScript (JS)

Get 5 Hours of FREE PREMIUM Videos:

LearnVisualStudio.NET Free Preview


LearnVisualStudio.NET Free Preview: Declaring Variables and Assigning Values

I am a lifetime member of LearnVisualStudio.net and a Premium Plus member of dotNetVideos.net.

LearnVisualStudio.net is awesome because it grows in value each year as more videos are added.

dotNetVideos.net is also great because it focuses a lot on MS Certifications and practical interview questions.


- Wade Harvey (IdealProgrammer.com)

LearnVisualStudio Premium Videos

Visual C# 2010 for Absolute Beginners C# for Absolute Beginners C# for Absolute Beginners Study Guide Visual Basic for Absolute Beginners
Visual Basic Express Edition Study Guide Visual Basic 9.0 Language Enhancements Entity Framework Linq To Sql
Windows Phone 7 Development Unit Testing ASP.NET MVC 3 (In Progress) ASP.NET MVC Hands On Project
ASP.NET For Absolute Beginners Visual Web Developer C# Study Guide Visual Web Developer VB.NET Study Guide ASP.NET Controls Series
ASP.NET AJAX ASP.NET Architecture Series ASP.NET Server Controls Silverlight 4.0
Windows Presentation Foundation Windows Forms Controls Visual Studio 2010 New Features Visual Studio Team System 2008
Visual Studio Team System Features Getting Started With Sql Server Express Edition


dotNetVideos Premium Video Catalog

Interview Questions & Answers Windows AzureASP.NET MVC 4Windows Phone 7 (3 Videos)
Visual Studio 2011 Application Lifecycle ManagementLightSwitchHTML 5SOLID
Visual Studio Add-OnsVisual Studio 2010 ALM Lab ManagementASP.NET 4 Deep Dive Microsoft Enterprise Library 5 with ASP.NET 4 (10 Videos)
Virtualization Techniques for Developer (5 Videos)Test Series - 70-519: Designing and Developing Web Applications Using Microsoft .NET Framework 4 (20+ Videos)Test Series - 70-519: Supplemental
70-513: Test Series (MCTS) Windows Communication Foundation 4 (20+ Videos)70-515:Web Applications Development with Microsoft .NET Framework 4 (20+ Videos)Test Series - 70-516: Accessing Data with Microsoft .NET Framework 4 (20+ Videos)Test Series: 70-432: Microsoft SQL Server 2008, Implementation and Maintenance (20+ Videos)
Test Series: 70-433: SQL Server AdministrationFrom Novice To Professional - C# (25 Videos)From Novice To Professional - VB.NET (25 Videos)




Premium (Not Free) Video Tutorials

Free Video Tutorials & Free Tools

lang Example JavaScript (JS): HTML DOM Objects – Button Object – lang Example JavaScript (JS)

Purpose: – Illustrates the for the .

View Other Button Object Properties

Prerequistes:

Syntax: ButtonObject.lang="lang-code" – Allows you to access the language for a Button Object.

Restrictions: None

Notes:

  • You can build your own library of syntax examples by using same web site over and over and just add new files to it.

Instructions:

  1. Use Visual Web Developer 2008
  2. Create new web site;
    • Click File/New Web Site
    • Select ASP.NET Website Template
    • Select C-Sharp for language
    • name of Web Site could be JavaScript_Syntax.
  3. Folder

  4. Add New folder named "HTMLDOMObjects"
    • Right-click project name in solution explorer;
    • add new folder;
    • name of folder should be: HTMLDOMObjects
  5. Add New subfolder to "HTMLDOMObjects" folder named "DOMButton"
    • Right-click folder named "HTMLDOMObjects" in solution explorer;
    • add new folder;
    • name of folder should be: DOMButton
  6. Add New subfolder to "DOMButton" subfolder named "StandardProperties"
    • Right-click subfolder named "DOMButton" in solution explorer;
    • add new folder;
    • name of folder should be: StandardProperties
  7. Add HTML Page Named lang to StandardProperties subfolder
    • Right-click StandardProperties subfolder;
    • add new item;
    • Select HTML Page
    • HTML Page name should be lang
  8. Click on copy code in code below to copy code into HTML Page lang.htm
  9. Right-click on HTML page lang.htm and select view in browser
View Example In Browser

 HTML |  copy code |? 
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html>
  <head>
    <title>IdealProgrammer.com: lang </title>
    <!-- 
    ***************************************************
    * This example is from http://idealprogrammer.com *
    ***************************************************
    -->
    <style type="text/css" id="myStyle">
 
       .myButtons
        {
            font-size:large;           
            color:red;
        }
        .myButtons input
        {
        color:Blue
        }
 
        .myButton2
        {
            font-size:xx-small;
        }
        .myButton2 input
        {
        font-style :italic;        
        }
 
        .myButton3
        {
            background-color:#d0e4fe;
        }
        .myButton3 input
        {
        font-weight:600
        }
 
 
    </style>
    <script type="text/javascript">
 
        //****************************************************************
        //         Set Cookie
        //****************************************************************    
 function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
 
/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
 
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
 
//****************************************************************
//         Get Cookie
//**************************************************************** 
// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie(check_name) {
    // first we'll split this cookie up into name/value pairs
    // note: document.cookie only returns name=value, not the other components
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
    var cookie_name = '';
    var cookie_value = '';
    var b_cookie_found = false; // set boolean t/f default f
 
    for (i = 0; i < a_all_cookies.length; i++) {
        // now we'll split apart each name=value pair
        a_temp_cookie = a_all_cookies[i].split('=');
 
 
        // and trim left/right whitespace while we're at it
        cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
 
        // if the extracted name matches passed check_name
        if (cookie_name == check_name) {
            b_cookie_found = true;
            // we need to handle case where cookie has no value but exists (no = sign, that is):
            if (a_temp_cookie.length > 1) {
                cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));
            }
            // note that in cases where cookie is initialized but no value, null is returned
            return cookie_value;
            break;
        }
        a_temp_cookie = null;
        cookie_name = '';
    }
    if (!b_cookie_found) {
        return null;
    }
}
 
</script>			
 
   </head>
  <body id="myBodyID">
 
        Please click Buttons to change class assigned to button:<br /><br />
        <!--using onclick to set a cookie and reload page; 
        when page is reloading, we check that cookie to assign different styles to body
        -->
      <input id="Button1" type="button"  lang="en" class="myButtons"  value="button  " onclick="javascript: Set_Cookie( 'mycookie', '1', 30, '/', '', '' ); window.location.reload();" /><br /><br />
      <input id="Button2" type="button"  lang="es" class="myButtons" value="button - zh  (Chinese)" onclick="javascript: Set_Cookie( 'mycookie', '2', 30, '/', '', '' ); window.location.reload();"/><br /><br />
      <input id="Button3" type="button"  lang="fr" class="myButtons"  value="button - el (Greek)  " onclick="javascript: Set_Cookie( 'mycookie', '3', 30, '/', '', '' ); window.location.reload();"/><br /><br />
   <script type="text/javascript">
       //*****************************************************
       // DOM Objects
       //*****************************************************
 
 
       //*****************************************************
       //    ***    Button Object Properties   ***
       //*****************************************************
 
       //*****************************************************
       // lang
       //*****************************************************
 
       //    SYNTAX:
       //    object.lang="lang-code"  Allows you to retrieve or assign lang
       //       Here is a table of language codes:
       //Name of Language ISO 639-1 Code 
       //Afar aa 
       //Abkhazian ab 
       //Afrikaans af 
       //Akan ak 
       //Albanian sq 
       //Amharic am 
       //Arabic ar 
       //Aragonese an 
       //Armenian hy 
       //Assamese as 
       //Avaric av 
       //Avestan ae 
       //Aymara ay 
       //Azerbaijani az 
       //Bashkir ba 
       //Bambara bm 
       //Basque eu 
       //Belarusian be 
       //Bengali bn 
       //Bihari bh 
       //Bislama bi 
       //Tibetan bo 
       //Bosnian bs 
       //Breton br 
       //Bulgarian bg 
       //Burmese my 
       //Catalan; Valencian ca 
       //Czech cs 
       //Chamorro ch 
       //Chechen ce 
       //Chinese zh 
       //Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic cu 
       //Chuvash cv 
       //Cornish kw 
       //Corsican co 
       //Cree cr 
       //Welsh cy 
       //Czech cs 
       //Danish da 
       //German de 
       //Divehi; Dhivehi; Maldivian dv 
       //Dutch; Flemish nl 
       //Dzongkha dz 
       //Greek, Modern (1453-) el 
       //English en 
       //Esperanto eo 
       //Estonian et 
       //Basque eu 
       //Ewe ee 
       //Faroese fo 
       //Persian fa 
       //Fijian fj 
       //Finnish fi 
       //French fr 
       //Western Frisian fy 
       //Fulah ff 
       //Georgian ka 
       //German de 
       //Gaelic; Scottish Gaelic gd 
       //Irish ga 
       //Galician gl 
       //Manx gv 
       //Greek, Modern (1453-) el 
       //Guarani gn 
       //Gujarati gu 
       //Haitian; Haitian Creole ht 
       //Hausa ha 
       //Hebrew he 
       //Herero hz 
       //Hindi hi 
       //Hiri Motu ho 
       //Croatian hr 
       //Hungarian hu 
       //Armenian hy 
       //Igbo ig 
       //Icelandic is 
       //Ido io 
       //Sichuan Yi ii 
       //Inuktitut iu 
       //Interlingue ie 
       //Interlingua (International Auxiliary Language Association) ia 
       //Indonesian id 
       //Inupiaq ik 
       //Icelandic is 
       //Italian it 
       //Javanese jv 
       //Japanese ja 
       //Kalaallisut; Greenlandic kl 
       //Kannada kn 
       //Kashmiri ks 
       //Georgian ka 
       //Kanuri kr 
       //Kazakh kk 
       //Central Khmer km 
       //Kikuyu; Gikuyu ki 
       //Kinyarwanda rw 
       //Kirghiz; Kyrgyz ky 
       //Komi kv 
       //Kongo kg 
       //Korean ko 
       //Kuanyama; Kwanyama kj 
       //Kurdish ku 
       //Lao lo 
       //Latin la 
       //Latvian lv 
       //Limburgan; Limburger; Limburgish li 
       //Lingala ln 
       //Lithuanian lt 
       //Luxembourgish; Letzeburgesch lb 
       //Luba-Katanga lu 
       //Ganda lg 
       //Macedonian mk 
       //Marshallese mh 
       //Malayalam ml 
       //Maori mi 
       //Marathi mr 
       //Malay ms 
       //Macedonian mk 
       //Malagasy mg 
       //Maltese mt 
       //Moldavian mo 
       //Mongolian mn 
       //Maori mi 
       //Malay ms 
       //Burmese my 
       //Nauru na 
       //Navajo; Navaho nv 
       //Ndebele, South; South Ndebele nr 
       //Ndebele, North; North Ndebele nd 
       //Ndonga ng 
       //Nepali ne 
       //Dutch; Flemish nl 
       //Norwegian Nynorsk; Nynorsk, Norwegian nn 
       //Bokmål, Norwegian; Norwegian Bokmål nb 
       //Norwegian no 
       //Chichewa; Chewa; Nyanja ny 
       //Occitan (post 1500); Provençal oc 
       //Ojibwa oj 
       //Oriya or 
       //Oromo om 
       //Ossetian; Ossetic os 
       //Panjabi; Punjabi pa 
       //Persian fa 
       //Pali pi 
       //Polish pl 
       //Portuguese pt 
       //Pushto ps 
       //Quechua qu 
       //Romansh rm 
       //Romanian ro 
       //Romanian ro 
       //Rundi rn 
       //Russian ru 
       //Sango sg 
       //Sanskrit sa 
       //Serbian sr 
       //Croatian hr 
       //Sinhala; Sinhalese si 
       //Slovak sk 
       //Slovak sk 
       //Slovenian sl 
       //Northern Sami se 
       //Samoan sm 
       //Shona sn 
       //Sindhi sd 
       //Somali so 
       //Sotho, Southern st 
       //Spanish; Castilian es 
       //Albanian sq 
       //Sardinian sc 
       //Serbian sr 
       //Swati ss 
       //Sundanese su 
       //Swahili sw 
       //Swedish sv 
       //Tahitian ty 
       //Tamil ta 
       //Tatar tt 
       //Telugu te 
       //Tajik tg 
       //Tagalog tl 
       //Thai th 
       //Tibetan bo 
       //Tigrinya ti 
       //Tonga (Tonga Islands) to 
       //Tswana tn 
       //Tsonga ts 
       //Turkmen tk 
       //Turkish tr 
       //Twi tw 
       //Uighur; Uyghur ug 
       //Ukrainian uk 
       //Urdu ur 
       //Uzbek uz 
       //Venda ve 
       //Vietnamese vi 
       //Volapük vo 
       //Welsh cy 
       //Walloon wa 
       //Wolof wo 
       //Xhosa xh 
       //Yiddish yi 
       //Yoruba yo 
       //Zhuang; Chuang za 
       //Chinese zh 
       //Zulu zu 
 
       // Two ways to retrieve lang
       document.write("<strong>Demonstrating Two Ways to Retrieve Property</strong><br />") 
 
         //   1. GetElementsByTagName
                myObject=document.getElementsByTagName('input')[0];
                document.write("Using getElementsByTagName: " + myObject.lang);
                document.write("<br />");
            //   2. GetElementById
 
                document.write("Using getElementById: ");
                document.write(document.getElementById('Button1').lang);
                document.write("<br />");
                document.write("<br />");
 
 
 
       // Two ways to assign lang
                if (Get_Cookie('mycookie')) {
 
                    ButtonNum = (Get_Cookie('mycookie'));
                }
                else {
                    ButtonNum = '1';
                }
 
                //   1. GetElementById
 
                if (ButtonNum == '2') {
                    document.write("<strong>Demonstrating Assigning Property with GetById</strong><br />") 
                    document.getElementById('Button2').lang = "zh"
                    document.write("Button2 lang changed to zh (Chinese): " + document.getElementById('Button2').lang + "<br />");
                }
            //   2. GetElementsByTagName
 
                if (ButtonNum == '3') {
                    document.write("<strong>Demonstrating Assigning Property with GetElementsByTagName</strong><br />") 
                    myThirdButton = document.getElementsByTagName('input')[2];
                    myThirdButton.lang = "el";
                    document.write("Button3 lang changed to el (Greek): " + myThirdButton.lang);
 
                }
 
 
 
 
   </script>
 
  </body>
</html>
 
 
 
 

Related posts:

  1. JavaSript (JS) dir Example: HTML DOM Objects – Button Object – JavaScript (JS) dir Example JavaSript (JS) dir Example: HTML DOM Objects - Button Object...
  2. JavaSript (JS) className Example: HTML DOM Objects – Button Object – JavaScript (JS) className Example JavaSript (JS) className Example: HTML DOM Objects - Button Object...
  3. JavaScript (JS) lang Example: HTML DOM Objects – Body Object – JavaScript (JS) lang Example JavaScript (JS) lang Example: HTML DOM Objects - Body Object...
  4. JavaScript (JS) lang Example: HTML DOM Objects – Area Object – JavaScript (JS) lang Example JavaScript (JS) lang Example: HTML DOM Objects - Area Object...
  5. lang Example JavaScript (JS): HTML DOM Objects – Anchor Object – lang Example JavaScript (JS) lang Example JavaScript (JS): HTML DOM Objects - Anchor Object...

Related posts brought to you by Yet Another Related Posts Plugin.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Powered by WP Hashcash

This blog uses the cross-linker plugin developed by Web-Developers.Net