Bible Verse Lookup

This document provides a simple example of how to use the lookup.js javascript tool to convert arbitrary scripture references in an HTML document into cross references to the SpiritAndTruth.org Lookup Bible. Here's how it works:

  1. Place the following line into the <HEAD> section of the HTML document containing the scripture references:

    <script type="text/javascript" src="https://www.spiritandtruth.org/lookup/lookup.js"></script>

  2. When the document is viewed in a web browser, all scripture references will be automatically converted to links. Clicking on a link will open the lookup Bible at the specified verse.
  3. Positioning the mouse over a scripture reference, causes a popup to display the passage.

    (This feature is presently restricted to documents served up within the SpiritAndTruth.org domain. Only clickable scripture references to open the lookup Bible work from documents served from other websites. We hope to remove this limitation in the future.)

  4. Click on the Bible translation link [e.g., '(NASB)'] in the popup to choose a different Bible translation.
  5. Click on the "More..." link at the end of the popup to open the Bible to view entire chapter containing the verse.

If you examine the source for this page, you would see that almost all the scripture links are just plain text without any markup. The links and popups are automatically added without any intervention by the author (other than inserting the single line mentioned above).

Inserting Explicit Links

For situations where lookup.js won't automatic link a verse, a verse can be explicitly specified.

Place in HTML File Result
A link to the <span verse="Gen. 3:15">protoevangelium</span>. A link to the protoevangelium.
A link to the <cite class="bibleref" title="Gen. 3:15">protoevangelium</cite> using Logos/Libronix citation markup. A link to the protoevangelium.

The verse or title attribute can specify any form of Bible address or abbreviation which lookup.js normally recognizes (e.g., "Ge. 3:15", "Gen. 3:15", "Genesis 3.15").

To restrict lookup.js verse recognition to explicitly marked verses only, set the following variable:

    <script type="text/javascript">window.LOOKUP_EXPLICIT_ONLY = true;</script>

Suppressing Link Underlining

In most cases, you'll want to set up your document styles so that links are only underlined when the mouse is actively over the link--this makes for a less distracting document appearance. This can be achieved by inserting the following into the <style type="text/css"> portion of the document header:

    <!-- 		
        a:link { text-decoration: none; }
        a:visited { text-decoration: none; }
        a:hover { text-decoration: underline; }
    -->

On Load of Document

If your document registers a callback functions (by directly setting onload or onunload) then for proper operation of lookup.js within older versions of certain web browsers you may have to modify your load functions to call the corresponding load functions previously registered by lookup.js:
    // Save lookup.js functions, if any.
    window.onloadchain = window.onload;
    window.onunloadchain = window.onunload;

    // Register my own load functions.
    window.onload = myOnLoadFunction;
    window.onunload = myOnUnloadFunction;
    . . .
    function myOnLoadFunction() {
        // Do my loading work . . .
        . . .
        // Start lookup.
        if (window.onloadchain) {
            window.onloadchain();
        }
    }
    function myOnUnloadFunction() {
        // End lookup.
        if (window.onunloadchain) {
            window.onunloadchain();
        }

        // Do my unloading work . . .
        . . .
    }
Feel free to contact us at contact@SpiritAndTruth.org if you have questions.


Typical Textual Example

The clearness and lucidity (perspicuity) of the Scriptures is their consistent theme (Deu. 29:29; Pr. 13:13; Isa. 5:24; Isa. 45:19; Mat. 11:25; Mat. 24:15-16; Luke 10:21, 26; 24:25; 2Ti. 3:16; 2Pe. 1:19). Yet if Scripture is meant to be understood, why do we have such a difficult time understanding it, and especially this book? Our problem is not so much the difficulty of understanding, but our own idolatry and rebellion. We are unwilling to study to know God and to submit in obedience to that which may be known. We are more interested in other pursuits than in seeking God through His revealed words of life (John 6:63, 68). As is often the case where Scripture is concerned, our inability to understand is more a reflection of our lack of zeal than the difficulty which attends the interpretation of God’s Word. When the average person in our country spends multiple hours in front of a television set daily, but “just can’t find the time” to read God’s Word, the issue is not one of time management, but idolatry.


Explicit Link Example

The following links utilize <span verse="address"></span> markup to explicitly specify links for text that would otherwise not be automatically recognized.

Valid Test Examples

The following examples are valid addresses which should be automatically linked:

Description Examples
Allow both semicolon and period as chapter-verse separator. John 3:16, 3.17.
Typical verse list. The Old (Mosaic) Covenant was “broken” and is “passing away” (Jer. 31:32; Heb. 7:21,22; 8:5-13; 10:9).
Verse list ending in punctuation or end of line. John 3:16. John 3:16; (John 3:16) [John 3:16] John 3:16-17
Short books. 1K. 1, 1 K. 1, 1P. 2.
Chapters or verses without intervening spaces Daniel 1,2,3 and Revelation 12:1,2,3.
Chapters alone (without verses). Daniel 2, 4 and Revelation 12 and other text.
Grouping of book number when only spaces intervene two addresses. (Should parse as "Revelation 1" followed by "1 Cor 1".) Revelation 1 1 Cor 1.
Appended verse specifiers (a-d, ff., cf.). John 1:1a; 2:3c-7b,9ff.; (Gen. 3:16ff) John 1:1; cf. 2:3
Confer with specified book. Jer. 30:7 cf. Dan. 12:1.
Variations in book abbreviations. Pro. 1:1; Prov. 1:1; Prv. 1:1; Mtw 1:1;
Examples from various documents which previously failed to parse in the past. Isa 44:2,24;
Explicit link using <span verse="address"></span> format. This links to the sixteenth verse of the third chapter of the Book of John.
Explicit link using <cite class="bibleref" title="address"></cite> Libronix citation format. This links to the sixteenth verse of the third chapter of the Book of John.

Invalid Test Examples

The following examples are invalid addresses which shouldn't be linked:

Description Examples
Book names which are too short. G 1; G. 1; M 1:1; M. 1:1; K 2.
Date ("Jan") should not match possible abbreviation for Joshua ("Ja") since too long. Wed Jan 8 16:13:05 2014
Numbers which are not associated with Bible books. A period of 3.5 years. A ratio of 3:1.
Invalid (out-of-range) chapters or verses. Mat. 0, 1:0, Acts 29:1, Acts 28:32.
Text that has similarity to book name. Part 1 ("Part" incorrectly matched "Proverbs"), Johns 3 (extra letter in bookname).