There are two ways to place javascript directly on a web page inside a KRL rule set. Through an emitting block or external resource. Let them first discuss what happens to the blocks.
. heredoc clownhats, .
javascript :
rule emitter {
select when web pageview "exampley.com"
{
emit <|
$K("body").append("Hello from a rule.");
|>;
}
}
javascript :
global {
emit <|
$K("body").append("Hello from the global block.");
|>;
}
javascript KRL - .
, javascript - :
use javascript resource "url-to-resource"
, javascript, my-personal-website.com/awesome.js:
$K("body").append("Hello from an external resource.");
:
meta {
use javascript resource "my-personal-website.com/awesome.js"
}
, javascript KRL:
ruleset a369x151 {
meta {
name "fun-with-javascript"
description <<
fun-with-javascript
>>
author "AKO"
logging on
use javascript resource "http://dl.dropbox.com/u/4917848/js/example-external-resource.js"
}
global {
emit <|
$K("body").append("<br/>Hello from the global block.");
|>;
}
rule emitter {
select when web pageview "exampley.com"
{
emit <|
$K("body").append("<br/>Hello from a rule.");
|>;
}
}
}
exampley.com:

, bookmarklet .