Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
Pedro Coelho
MVP
20
Views
4
Comments
[HttpRequestHandler] Add a new action for javascript script's
Question
Hello all
In HttpRequestHandler there is a nice little action that adds a <script> tag to the <head> section.
The problem is that it only adds a <script> tag using the src parameter and not a entire script.
It does something like:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
but it would also be useful to have something like:
<script type="text/javascript">
....
</script>
As such I propose a possible solution to an action
AddJavaScript
to be added to the HttpRequestHandler extension:
In HttpRequestHandler.cs add
public void MssAddJavaScript(string ssJavaScriptSource, bool ssDefer, string ssCharset) {
HeadFilter hf = GetHeadFilter();
hf.AddJavaScript(ssJavaScriptSource, ssDefer);
}
In HeadFilter.cs add
public void AddJavaScript(string JavaScriptSource, bool defer) {
AddScript("text/javascript", JavaScriptSource, defer);
}
public void AddScript(string Type, string SRC, bool defer) {
if (defer) {
scriptTags.AppendFormat("<script type=\"{0}\" defer=\"defer\">{1}</script>", Type, SRC);
} else {
scriptTags.AppendFormat("<script type=\"{0}\">{1}</script>", Type, SRC);
}
}
Pedro Coelho
MVP
If you like this idea give it a "Like" in
https://www.outsystems.com/ideas/939/
:)
João Rosado
Staff
Hi Pedro
That already exists.
Is called "RunJavaScript" in the HTTPRequestHandler. Not sure if it's implemented like that, but has the same effect.
(If you are using a old version of the platform think it was included on the RichWidgetsExtension extension before)
Regards,
João Rosado
Pedro Coelho
MVP
João,
I'm not 100% sure on this, but I think the RunJavaScript puts the script at the current "location" of the HTML not at the <head> section. I was checking the extension for the implementation and it only has the following code:
public void MssRunJavaScript(string ssScript) {
AppInfo.GetAppInfo().OsContext.QueueJavascript(ssScript);
}
Since we don't have the code for the Outsystems.HubEdition.RuntimePlatform.AppInfo class I cannot validate the implementation details.
This request for the <head> section has some importance in Google Api's for instance where you need to do something like
google
.
load
(
"jquery"
,
"1.6.4"
) before anything else in the page.
Best regards,
PC
João Rosado
Staff
Hi Pedro,
Ok, missread a bit..
Either write that on a Javascript property, or in an unescaped expression.
Don't need to be on the head part.
Alternativelly ..if you really really want to put add that on the Head, you can use the AddPostProcessingFilter.
But I think it's a overkill.
Regards,
João Rosado
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...