If you want to get HTML editor within MS Access form, there are couple of solutions available. The free solution I know is to get Not So Elegant HTML Editor. The problem with this editor is that
- After looking at this editor, you will never say “so cool”
- It is good for basic editing but many important functionality like “Table” editing is missing.
When I had to create HTML Editor within MS Access form, I asked the question to myself “Why to reinvent the wheel?” and the solution I came up with has the main benefits
- It is completely FREE
- When users will look at it, they will definitely say “so cooooool”.
- Rich feature set
- XHTML compliant code will be generated and hence output can be used anywhere.
- Plugin based architecture can help add extra cool features
Here is a sample of how this editor would look like Read more…
In your MS Access application, if you are using Microsoft Web browser, we may have to interact with the Javascript variable inside the loaded page. There is no obvious method exists in the Web browser control but using the following trick you can get/set the Javascript variable in the webpage.
Quick Tip:
Add Javascript function to get/set the value of Javascript variable/ HTML element from/to the hidden field. Execute the function using VBA code with the help of DOM functions available in VBA. Please read further for the details or download the code. Read more…
If you want to remove URL from the Lookup columns in SharePoint, just copy and paste the following code into the page.
<div id="scriptdiv"></div>
<script language="javascript">
var CTXMAX = 5;
function RemoveLookupAfterPageLoad()
{
var table, i=1, ctx;
// Remove lookup links
while(i<=CTXMAX)
{
eval("if(typeof ctx" + i + " != 'undefined') ctx = ctx" + i +"; else ctx = null");
i++;
if(!ctx)
break;
table = document.getElementById(ctx.listName + "-" + ctx.view);
if(table)
{
table = table.parentNode;
table.innerHTML = RemoveLookupLinks(table.innerHTML);
}
}
}
function CreateDynamicFunction()
{
// Create a function "ExpGroupCallServerg_GUID"
var scriptdiv = document.createElement("div");
var i=1, funcExpGroup ="", ctx, val;
if(browseris.ie)
document.getElementById("scriptdiv").appendChild(scriptdiv);
while(i<=CTXMAX)
{
eval("if(typeof ctx" + i + " != 'undefined') ctx = ctx" + i +"; else ctx = null");
i++;
if(!ctx)
break;
funcExpGroup = funcExpGroup + "function ExpGroupCallServerg_{0}(arg, context){\n" +
"globalArg_g_{0} = arg; globalContext_g_{0} = context;\n" +
"setTimeout(\"WebForm_DoCallback('ctl00$m$g_{0}',globalArg_g_{0},Interceptor,globalContext_g_{0},ExpGroupOnError,true)\", 0);\n}\n";
funcExpGroup = funcExpGroup.replace(/\{0\}/g,ctx.view.toLowerCase().replace("{","").replace("}","").replace(/-/g,"_"));
}
scriptdiv.innerHTML = " <script" + " defer>" + funcExpGroup + "</" + "script>";
if(!(browseris.ie))
document.getElementById("scriptdiv").appendChild(scriptdiv);
scriptdiv.style.display="none";
}
CreateDynamicFunction();
//Ajax function interceptor
function Interceptor(htmlToRender, groupName)
{
ExpGroupReceiveData(RemoveLookupLinks(htmlToRender), groupName);
}
//Function which removes links using regex
function RemoveLookupLinks(htmlToRender)
{
return htmlToRender.replace(/<a[^>]*RootFolder=\*[^>]*>([^<]*)<\/a>/gi,"$1");
}
//Queue up the function to execute after page load
_spBodyOnLoadFunctionNames.push("RemoveLookupAfterPageLoad");
</script>
The function “getTagFromIdentifierAndTitle” is used by SharePoint particularly for changing form fields. But it is good enough only if you have straight forward fields. If you have enabled “Fill-in” values, it will not be able to find the correct element. Here is a extended version of this function to get the “Fill-in” enabled field.
function getTagFromIdentifierAndTitle(tagName, identifier, title)
{
var len = identifier.length, colonindex, splittitle, taglen, titlelen = title.length, slen;
var tags = document.getElementsByTagName(tagName);
for (var i=0; i < tags.length; i++)
{
var tempString = tags[i].id;
taglen = tags[i].title.length;
if(taglen<titlelen)
continue;
splittitle = tags[i].title.replace(title,"");
slen = splittitle.length;
if(slen == taglen || (slen > 0 && splittitle.indexOf(":") == -1))
continue;
if ((identifier == "" || tempString.indexOf(identifier) == tempString.length - len))
{
return tags[i];
}
}
return null;
}
Would you like to crash FreeTextBox? Here is the trick. Visit the page http://freetextbox.com/demos/Default.aspx
Click on HTML view and copy/paste the following code.
<script language="javascript">alert("Hi");</script>
Hello
Press “Save” button. This will convert your code into
<script language="javascript">
<![CDATA[lert("Hi");]]>
</script>
Hello
Note that “a” is missing. Pretty interesting!!! hmmmmmm….
Now again click on HTML view and copy/paste following code
<script language="javascript">
<![CDATA[alert("Hi");]]>
</script>
Hello
Now you will see error….. Hurray…… You crashed FreeTextBox !!!!!!!!!!!!!!!!
Now you might think how can I write javascript in FreeTextBox? Here is the solution.
<script language="javascript">
<!-- alert("Hi"); -->
</script>
Hello
Now it will perfectly show you script and will execute without any problem.
First of all guess the result and then get the actual answer by clicking on the button “Show Result”
parseInt(“04″)=?;
parseInt(“08″)=?;
In Javascript if the string starts with “0″, the string will be
parsed as if it is octal number. (i.e. base
instead of decimal
number(i.e. base 10).
So if you are parsing the string containing integer value and fear about leading zeroes, always specify the base as shown below.
parseInt(“04″,10); (here 10 is the base)
parseInt(“08″,10);
function doGetCaretPosition (ctrl) {
var CaretPos = 0; // IE Support
if (document.selection) {
ctrl.focus ();
var Sel = document.selection.createRange ();
Sel.moveStart ('character', -ctrl.value.length);
CaretPos = Sel.text.length;
}
// Firefox support
else if (ctrl.selectionStart || ctrl.selectionStart == '0')
CaretPos = ctrl.selectionStart;
return (CaretPos);
}
function setCaretPosition(ctrl, pos){
if(ctrl.setSelectionRange)
{
ctrl.focus();
ctrl.setSelectionRange(pos,pos);
}
else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
Here “ctrl” is the Textarea object. This script works well with Internet Explorer, Firefox and Opera.
You can check it at Get/Set Caret in Textarea Example