Actions

KRL supports a number of build-in actions. The purpose of an action is to produce JavaScript that is executed on the browser.

To learn about actions in the context of a rule please refer to the guide on rules

after(<selector>, <html>)

Place the the <html> after (as a sibling of) the element selected by <selector>.

after("#foo", "<p>This is the text</p>")

alert(<message>)

Pop an alert box on the client with the message given in the argument string.

alert("Surprise!")

annotate_local_search_results(<selector_func>)

Annotates Google, Bing, and Yahoo! local search results according to the result of applying <selector_func> to each result.

annotate_local_search_results("my_function")

annotate_search_results(<selector_func>)

Annotates Google, Bing, and Yahoo! search results according to the result of applying <selector_func> to each result.

annotate_search_results("my_function")

append(<selector>, <html>)

Append the <html> to the inside of the element selected by <selector> as the last child.

append("#foo", "<p>This is the text</p>")

before(<selector>, <html>)

Place the the <html> before (as a sibling of) the element selected by <selector>.

before("#foo", "<p>This is the text</p>")

float(<position>, <vertical>, <horizontal>, <url>)

Float a window above the current contents of the browser (z=.9999). This is not a pop-up.

float("absolute", "top: 10px", "right: 10px", "/cgi-bin/weather.cgi?city=" + city + "&tc=" + tc)

float_html(<position>, <verical>, <horizontal>, <expr>)

Like float but content from evaluating the expression rather than a URL.

float_html("absolute","top:50px","right:50px","<h1>I'm Floating HTML!</h1>")

let_it_snow()

Makes it... snow!

let_it_snow()

move_after(<anchor>, <item>)

Move the element with the id given by item just after the element with the id given by anchor

move_after("#item_to_move_after", "#item_to_move")

move_to_top(<item>)

Move the element with the id given by item to the top of whatever container it's in.

move_to_top("#foo")

noop()

This action does nothing, because rules must have an action, this action is available.

noop()

notify(<header_text>, <message>)

Place a notification over the page. Similar to Growl notification on OS X.

notify("Header","This is the message part")

close_notification(<selector>)

Attach a close event for a notification to an element or set of elements identified by the selector string that is the argument.

close_notification("#id_selector")

percolate(percolate_function)

Percolates search results based on a user-written function.

percolate(user_written_javascript_percolate_function);

popup(<top>, <left>, <width>, <height>, <url>)

Pop up a window above the current contents of the browser. This is a pop-up.

popup(250, 250, 150, 400, "/kynetx/google_ad.inc")

prepend(<selector>, <html>)

Prepend the <html> to the inside of the element selected by <selector> as the first child.

prepend("#foo", "<p>This is the text</p>")

redirect(<url>)

Redirect to the given URL.

redirect("http://www.google.com")

replace(<sel>, <url>)

Replace the page element (usually a <div>) with the element selected by <sel> with content given by the URL.

replace("#foo", "http://www.google.com/")

replace_html(<sel>, <expr>)

Replace the page element (usually a <div>) with the id given by <sel> with content given by the result of evaluating the expression.

replace_html("#foo", "<p>This is the text</p>")

replace_inner(<sel>, <expr>)

Replace the contents of the page element with the id given by <sel> with content given by the result of evaluating the expression (a string, var, extended quote, or string concatenation).

replace_inner("#foo", "This is the text")

replace_image_src(<sel>, <url>)

Replace the source of the image tag having ID of <sel> with the given URL. The effect is that the picture changes without flicker on modern browsers if the image tag has height and weight attributes and replacement image has the same size.

replace_image_src("#foo", "http://example.com/image.jpg")

set_element_attr()

set's an element's attribute to a given value

set_element_attr()

sidetab()

Creates a slide-out tab.

sidetab()

watch(<selector>, <event>)

Watch the element identified by the given selector for the specified event type. This action is used to bind events to page elements for later processing.

watch("#myform", "submit")