function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
arasuarasu 

How can I include a ".js" (dot javascript) file in an S-Control?

Hi,
 
How can I include a ".js" (dot javascript) file in an S-Control?
 
Appreciate all your responses in this regard. Please note that the extension of the file is ".js".
Thanks for your responses.
 
Thanks and regards,
Ambili
NazeerNazeer
Arasu,

To use your own JS, just store your script in any doument folder and get exact link.
then you can put it on your Script with detailed location of js file.

thx - Nazeer,
Chennai



Greg HGreg H

Another option is to store your javascript file as a sControl then call the sControl using a script tag within the "head" of your HTML.

Code:

<script src="{!LEFT($SControl.your_javascript_file_js,48)}" type="text/javascript"></script>

 

-greg

arasuarasu

Hi Greg,

As suggested, I created an S-control as a "Snippet" for the javascript file and then called it as follows from the other S-control that uses it.

<script src="{!LEFT($SControl.tooltip_js,48)}" type="text/javascript"></script>

but still it is not able to load this object. Am I going wrong somewhere?

Appreciate you feedback in this.

Thanks,
Ambili

Greg HGreg H
Change the type from Snippet to HTML and you should be good-to-go...
-greg
arasuarasu

Hi Greg,

I changed the scontrol to snippet, but still it the file fails to load. It throws object expected error when I run my main s-control. Please find the head portion o fmy main S-control that shows link to the js file(in red).

<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Alliance Approvals</title>
<script language="JavaScript" type="text/javascript">
window.top.document.title = "BD Approvals - Salesforce Enterprise Edition ";
</script>
<script language="JavaScript1.2" src="/soap/ajax/10.0/connection.js"
 type="text/javascript">  
 </script>
<script src="{!LEFT($SControl.Scontrol_Common_functions,48)}" type="javascript"></script>

<link href="/sCSS/9.0/1184184680000/Theme2/default/ie/elements.css"
 media="handheld,print,projection,screen,tty,tv" rel="stylesheet"
 type="text/css" />
<link href="/sCSS/9.0/1184184680000/Theme2/default/ie/common.css"
 media="handheld,print,projection,screen,tty,tv" rel="stylesheet"
 type="text/css" />


I have no clue why this is not working. Is there any other way to include a .js file?

Please advise.

Thanks,

Ambili