Link to home
Start Free TrialLog in
Avatar of oosterbaan
oosterbaan

asked on

how to handle javascript whitin notes ?

Hi experts,

I did found a few javascripts I want to use in the databases I'm builing (for web purposes), but I don't know how to "import" those scripts into the application.

The remark with those scripts is saying to:

first - Copy the coding into the HEAD of your HTML document

second - Add the onLoad event handler into the BODY tag

third - Put the last coding into the BODY of your HTML document  

How do I do this in Notes R5 ?

Greetings,

Bob
Avatar of HemanthaKumar
HemanthaKumar

Create a field called $$HTMLHead a computed for display field and paste all of the head js code (watch quotes).

[<Body onload="make a call to js function">]

Then paste or code all of ur html within the [] like this for eg:

[<input type=button name="xxx" value="yyy" onClick="do something">]


Just use your form as html editor

In R5 you can use pages to hold js code and import it into the script tag. But the above method would be simple to start with.

~Hemanth

Avatar of oosterbaan

ASKER

Please help me out...

The code that I found starts like this:

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function mklist(n)
{
  this.length=n;
  for (var c=1 ; c <= n ; c++) {
    this[c]=0;
  }
  return this;
}

And ends with this:


    window.clearTimeout(window.config.timer);
    window.config.timer=window.setTimeout('sbprint()',window.config.delay);
  }
}
//  End -->
</script>

What do I need to paste into the $$HTMLHead field ? because when I paste this code, error message's appears.

Do I need to add the [ character somewhere or leave lines out ?

Greetings,

Bob
Instead of using $$HTMLHead, paste the code directly into the form like this

[<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function mklist(n)
{
 this.length=n;
 for (var c=1 ; c <= n ; c++) {
   this[c]=0;
 }
 return this;
}

And ends with this:


   window.clearTimeout(window.config.timer);
   window.config.timer=window.setTimeout('sbprint()',window.config.delay);
 }
}
//  End -->
</script>
</HEAD>

<Body onLoad="mklist()">
Any HTML code here....
</Body>
</HTML>]

Avatar of CRAK
Hemanth,
Why the $$HTMLhead-field? He's using R5....

All he needs is copy the actual JS-code:

function mklist(n)
{
 this.length=n;
 for (var c=1 ; c <= n ; c++) {
   this[c]=0;
 }
 return this;
}
...
etc.
...
   window.clearTimeout(window.config.timer);
   window.config.timer=window.setTimeout('sbprint()',window.config.delay);
 }
}

and paste it in the JS header-event of a form or page. I agree with you that the $$HTMLhead-field works to -even on R4.x servers-, but this is much easier!
Additional advantages: you dan't have to worry about those quotes and the different colors help to make it readable.


Similar to that: paste "mklist()" (without quotes) in the onLoad event of the forms or pages onLoad-event.

ASKER CERTIFIED SOLUTION
Avatar of zvonko
zvonko

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello CRAK <|;-)
Hi zvonko!
I see you're reaching for your "first" T-shirt again? You're going fast!
How much time do you spend on EE anyway?
True, but I want to keep it simple. And also downward compatibility ;-)
You think I do this for this fantasy T-shirts (ha ha ha)...
untill now I got only ONE!!!

How much t-****s do you have CRAK? ;-)

...anyway you are right: I spend too much time here (still I wonder when Heman is sleeping :-))
One more last question,

I have tried zvonko's option with the JS header and Onload attributes, and this is working fine, but is it possible to add more the one javascript into these attributes ?

Greetings,

Bob
Sure you can: put every instruction on a new line.
If you want to do it right, close every line with a semi-colon (";").
In fact you could even use the semi-colons, without newline:
alert('statement 1'); alert('statement 2')

If things get complicated you could add new functions in JS Header, and address those in the form events:

JS Header:
function alerts(parm)
{
 alert(parm);
 alert('statement 1');
 alert('statement 2');
}

onLoad:
alerts('1st time');
alerts('2nd time');
zvonko,
I got over 5000 pt for notes just about two weeks ago. I'm waiting for the "T-shirt problems" (see "what's new") to get solved now, so I can finally see if it's worth wearing it.
Next target: top 15!?
Pitty this guy "stamp" is still there.... I wonder who's on #16!  ;-))
...we will see (said the blind man ;-))
Thanks guys
Bob, thank you for the points ;-)