Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: Code Snippets - JavaScript

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Tue, Sep 20, 2011, 1:01 PM


{outline||<1> - }

Displaying the current URL

The following javascript will output the URL of the page in which the javascript is running.

document.write(document.URL);

Displaying the Document Timestamp

The following JavaScript code will output when the document was last updated.

document.write(document.lastModified);

Setting Initial Focus

To set the control with the initial focus on a web page, perform the following steps.

  • Browse to the page.
  • View the HTML source for the page and find the ID of the control of interest
  • Place the following code near the BOTTOM of the body of the page, changing "myControlId" appropriately.

document.getElementById("myControlId").focus();

Submitting a Form

document.forms[0].submit();

Applying Alterating Formats to a Table

The following JavaScript code assumes that the formats for classes even and odd are defined somewhere in your CSS code.

function recolorTable() {

    var rows = '#MyTable tbody tr'
    $(rows).removeClass('even').removeClass('odd');
    $(rows + ':visible:even').addClass('even');
    $(rows + ':visible:odd').addClass('odd');
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.