Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: if ~ else

  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts

    if ~ else

    Code:
    if (FCKBrowserInfo.IsIE) FCKScriptLoader.AddScript('js/fckeditorcode_ie_1.js');
    else FCKScriptLoader.AddScript('js/fckeditorcode_gecko_1.js');};
    Would you explain what the code above means?
    Get my greedy up

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's using an already generated browser type object to check if the browser is Internet Explorer and then calling a function who's apparent function (based on the name being displayed) is to cause another javascript file to be loaded into the page. The URL of the file to be loaded is dependant on whether the browser is IE or not. It can also be noted that based on the names of those scripts it loads some browser specific JS code into the web page.

    Make sense?
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Hard to explain in detail what it does without seeing the definitions of the FCKBrowserInfo FCKScriptLoader, but in the large this is what I can read out of it:

    01: If the browser is ie, go to instruction 04
    02: Load the script file "js/fckeditorcode_gecko_1.js"
    03: Go to instruction 05
    04: Load the script file "js/fckeditorcode_ie_1.js"
    05: End

    So, what is does is to simply load one file for standards compatible browsers and one for ie. Whatever else happens depends on the loaded file.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Seoul, Korea
    Posts
    329
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if (FCKBrowserInfo.IsIE) FCKScriptLoader.AddScript('js/fckeditorcode_ie_1.js');
    else FCKScriptLoader.AddScript('js/fckeditorcode_gecko_1.js');};

    The code is coming from large code which is downloaded at http://www.fckeditor.net/Demo.

    I don't need all funtions of the Demo.
    I need just one function which is the button "Source."

    So I am on the way of removing all code which are not related to my concern.

    Now I need "('js/fckeditorcode_ie_1.js')" but I don't need "('js/fckeditorcode_gecko_1.js')"

    How can I remove "('js/fckeditorcode_gecko_1.js')"?

    I tried the following code instead of the above code, but the following code
    doesn't work corectly.
    Code:
    if (FCKBrowserInfo.IsIE) FCKScriptLoader.AddScript('js/fckeditorcode_ie_1.js');
    How could I make the above code correctly without "else condition?"
    Get my greedy up

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you only need one of those then:

    <script type="text/javascript" src="js/fckeditorcode_ie_1.js"></script>

    is all you need. However unless you are targeting an IE only audience I doubt that removing that javascript is a wise thing to do, you'll just be breaking the code for anyone who doesn't have IE.
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •