Getting Started in Embedding

This tutorial assumes that the volunteer has at least some experience in support. How support works, wording, etc. are all learned from experience and entries other than this one.



What is embedding? It's displaying your LiveJournal-hosted journal within your webpage. The possibilites range from simply displaying your LiveJournal as is and putting it in a frame on your site to displaying a customized version using a scripting language.

Be sure to review the Embedding Developer page and watch for update announcements as it may be updated in the near future. Also be sure to read the Summary Codes entry, Policies entry [updated 17 February 2003], and the Category Definition entry. Additionally, review the FAQs referenced throughout this document.

Often, a user will simply want to know how to embed their journal into their webpage. This involves simply providing a FAQ reference.

If the user doesn't mention where their site is embedded, or provide the code they're using, try looking in their userinfo for a website link. Look around their website for any sign of a "journal" or "blog" page. If one isn't provided, wait for a supporthelp to request further information.

Frequently a user will have already embedded their journal and need further assistance. Usually, this comes in the form of wondering why their embedded journal is so "ugly," the date is orange, or is missing comment links. This is indicative of the user simply copying the embedding method exactly including the styleid=101 reference. Style 101 is rather plain (white, black and orange), is missing comment links, and does have a few problems. The user should be directed toward this FAQ.

It's also good to familiarise yourself with the most common embedding methods, which at present are frames and JavaScript. There are two frames methods: <frameset>, and <iframe>.

The first is the original HTML "frameset" which produces one page displayed next to another, at it's most basic form. A very primitive form of this is an example here. This works for any frame-supporting browser (nearly all of them these days), but one can also include a <noframes> clause to provide an alternative should framesets not work.

The second is the inline frame, more commonly known as an iframe. This allows you to put the frame wherever you would like within a specific page, rather than having it confined to sets of frames around each other. A primitive example of this may be viewed here (note my default style doesn't work very well in such a small area).

The easiest method for paid users to use is the JavaScript method. This script basically tells the browser -- by the appended &enc=js to the customview.cgi URL -- to print the entire journal page from one (often very large) document.write statement. This puts any style within a document.write automatically and puts in \n (line break in many scripting/programming languages) wherever a line break occurs. For those unfamiliar with JavaScript, document.write is used to print text (or media) to the screen. A simple example of this may be viewed here. You may want to examine the source code of of the JS-encoded Generator by going here and viewing source.

It's possible for a free user to use JavaScript, with a slightly more complicated script that doesn't involve customview.cgi but rather pulling up your journal as the frames methods do. However, this shouldn't be given as an answer when a user is seeking a method; our official position on this is leaving it as an "easter egg" for users smart enough to find it.

There are three known, system-created embedding styles: Style 101 as referenced above, Style 103 used for Flash, and Style 408, a "fixed" public version of 101. I'm currently attempting to have Style 101 marked public, but you may want to look over the style information for 103 and 408.

Frames and JavaScript, in addition to being the easiest embedding methods, are also the only two able to display protected and private entries utilising the &checkcookies=1 parameter to customview.cgi. This is addressed in this FAQ. Browsers (or "client-side") need to check their cookies against the current server. Since the frames and JavaScript are both directly pulling the journal from LiveJournal.com, the browser is able to authenticate a user and display protected/private entries. The other methods are pushing the journal through a script, which is "server-side," so the browser is unable to authenticate the cookies-to-site match and therefore unable to display protected/private entries.