Using the ESV Bible Javascript Syndication
With one line of Javascript code, you can make the ESV appear on your site in any browser that has Javascript enabled (roughly 90% of all browsers). You do not need to apply for an access key to use this code on your site.
Daily verse
Paste the following code on your page. A new verse will appear each day.
<script type="text/javascript"
src="http://www.gnpcb.org/esv/share/js/?action=getDailyVerse"></script>
All verses have audio available. Use the following code to add a "listen" link to the audio.
<script type="text/javascript"
src="http://www.gnpcb.org/esv/share/js/?action=getDailyVerse&include-audio-link=true"></script>
Today’s verse (if you have Javascript enabled)
Show any passage
How to do it
First, create a page on your website. Note the address (e.g., http://www.example.com/bible.html).
Second, create a form on the page with the following code. (Replace http://www.example.com/bible.html with the address of your page.)
<form action="http://www.example.com/bible.html" method="get">
<input type="text" name="passage" />
<input type="submit" value="Search the Bible" />
</form>
Third, add the following code to your page where you want the text to appear:
<script type="text/javascript">
var myDate = new Date;
var myUrl = "http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&time=" + myDate.getTime();
document.write('<script type="text/javascript" src="' + myUrl + '"></s' + 'cript>');
</script>
(The time parameter prevents some browsers, notably Internet Explorer 7, from caching the script.)
Fourth, visit the page. Enter a passage (e.g., John 1), click the Search the Bible button, and the passage should appear. If it doesn't, please see the Troubleshooting section below.
Fifth, we strongly suggest that you add the following line to the <head> of your document. It will supply correct indentations and superscript verse numbers.
<link rel="stylesheet" type="text/css" href="http://www.gnpcb.org/esv/assets/style/text.css" />
Advanced options
Setting a passage
You can include an explicit passage as part of the url for the script:
<script type="text/javascript"
src="http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=John+1">
</script>
In fact, you must include a passage if you want it to work on certain browsers. You can use a server-side scripting language such as PHP to add the necessary information:
<script type="text/javascript"
src="http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&passage=<?php
print isset($_GET['passage']) ? urlencode($_GET['passage'])
: '';
?>">
</script>
If you know a cross-platform (ie, works in all version 5 and later browsers, including Mac IE5), Javascript-only way to set the src dynamically, we would like to hear about it. Please email webmaster@gnpcb.org.
Javascript variables
The script sets the variable contentOk = 1 if no errors occurred. It sets contentOk = 0 and creates a variable esvError containing an error message if there was a problem. (eg, if someone entered a passage that doesn't exist). For example, you could use the following code in a separate <script> tag:
<script type="text/javascript">
if (typeof contentOk == 'undefined') document.writeln("Sorry,
your browser can't search the Bible from this site.");
else if (contentOk == 0 && esvError) document.writeln(esvError);
</script>
Other options
You can also add any of the following options to the query string. For example, to exclude footnotes, you would use:
<script type="text/javascript"
src="http://www.gnpcb.org/esv/share/js/?action=doPassageQuery&include-footnotes=false">
</script>
| Option | Default | Description |
|---|---|---|
| include-passage-references | true | Include <h2>s that indicate which passage is being displayed. For example: Isaiah 53:1-5. |
| include-first-verse-numbers | true | Show the verse number (e.g., 53:1) at the beginnings of chapters. |
| include-verse-numbers | true | Show verse numbers in the text. |
| include-footnotes | true | Include footnotes and references to them in the text. |
| include-footnote-links | true | If you have set include-footnotes to true, set this option to false to turn off the links to the footnotes within the text. The footnotes will still appear at the bottom of the passage. If include-footnotes is false, this parameter does not do anything. |
| include-headings | true | Include section headings. For example, the section heading of Matthew 5 is The Sermon on the Mount. |
| include-subheadings | true | Include subheadings. Subheadings are the titles of psalms (e.g., Psalm 73's A Maskil of Asaph), the acrostic divisions in Psalm 119, the speakers in Song of Solomon, and the textual notes that appear in John 7 and Mark 16. |
| include-surrounding-chapters | false | Show links under the reference to the previous, current (if not showing the whole chapter) and next chapters in the Bible. The link points to the ESV website, but you can modify it by changing the link-url parameter. |
| include-word-ids | false | Include a <span> tags surrounding each word with a unique id. The id has several parts; the id "w40001002.01-1" consists of: the letter w (needed for XHTML ids), an eight-digit verse identifier (40001002 indicates Matthew 1:2), a period (.), a two-digit word identifier (01), and a hyphen followed by a number (this number is incremented with each passage; it starts with 1). Footnotes do not have word ids. |
| link-url | http:// www.gnpcb.org/ esv/search/ | Where embedded links to other passages should point. It currently applies only when include-surrounding-chapters is set to true. |
| include-audio-link | true | Include a link to the audio version of the requested passage. The link appears in a <small> tag in the passage's identifying <h2>. |
| audio-format | real | Takes a value of flash, mp3, real, or wma to indicate the format of the audio. It defaults to real for historical reasons, but the default could change (to flash); if you have a strong preference for one of these formats, we recommend that you specify it explicitly. We recommend flash as the most flexible; an embedded Flash player is included in the text. The mp3 option includes a link to an M3U file. However, this link expires after about 24 hours, making it unsuitable for extended caching. The other two options, real and wma, only have New Testament recordings by Marquis Laughlin available. (The real option refers to RealAudio, and wma refers to Windows Media.) |
| audio-version | mm | Which recording to use. The options are: mm (Max McLean, complete Bible), ml (Marquis Laughlin, New Testament only), and ml-mm (Max McLean for Old Testament, Marquis Laughlin for New Testament. Only affects the output if audio-format is flash or mp3. (Max McLean's version is only available in these two formats.) |
| include-short-copyright | true | Each passage from the ESV needs to include the letters "ESV" at the end of the passage. To turn off this behavior, set this option to false. |
| include-copyright | false | Show a copyright notice at the bottom of the text. Any page that shows the ESV text from this service needs to include a copyright notice, but you do not need to include it with each passage. Best practice is probably to include the copyright manually on your page, rather than download it every time. This option is mutually exclusive with include-short-copyright, which overrides include-copyright. |
Technical notes
The page on this server that serves the Javascript relies on the HTTP's REFERER header if no passage argument is included. Some browsers (notably Internet Explorer 5 for the Mac) do not send this information when they download scripts, making the normal method useless. For these browsers, you will need to include the passage as part of the <script src=""> statement. (See Advanced options.)
Troubleshooting
Terms and conditions
You do not need an access key, but you are restricted by the Conditions of the Web Service.
See it in action
- Scott Yang has written a useful javascript that automatically finds all Scripture references in a webpage, then creates links that make the ESV text appear in an iframe when you click them. It's easier to see than to explain.
- Visit Westminster Presbyterian Church to see it in action.
- Visit a test page on this server to see a simple example.
