View Full Version : if ~ else

09-29-2004, 11:11 PM
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?

Roy Sinclair
09-29-2004, 11:17 PM
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?

09-29-2004, 11:18 PM
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.

09-30-2004, 12:04 AM
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.

if (FCKBrowserInfo.IsIE) FCKScriptLoader.AddScript('js/fckeditorcode_ie_1.js');

How could I make the above code correctly without "else condition?"

Roy Sinclair
09-30-2004, 06:14 PM
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.