Log in

Embedding LiveJournal - All Methods


The simplest way to embed your journal into your website is to just insert this JavaScript wherever in your webpage HTML that you want your journal to show up. In browsers where JavaScript is unavailable, a link to your journal can be shown instead.


This JavaScript fragment loads JavaScript from LiveJournal. The special thing to note here is the &enc=js at the end of the customview.cgi arguments that tells LiveJournal to encode the page as one big document.write("...."); JavaScript command.

<script language="JavaScript"
<noscript><a href="http://username.livejournal.com/">View my LiveJournal</a></noscript>

HTML Frames

One way to hide www.livejournal.com from the URL and make your journal look like part of your site is using frames... put the HTML page with the <frameset> on your own server, and then make one of the frames be your journal. This method will work with any frame-supporting browser, including Netscape and Internet Explorer.

Additionally, HTML-4.0 compliant browsers are supposed to let you embed a frame inline with your page, so it doesn't have to be on the far side. This is called an <iframe>. Internet Explorer supports this, as do Netscape 6, Mozilla and all recent Opera versions. Inline frames aren't as compatible as normal frames, and won't work in Netscape 4. The following example shows an iframe:


For more information on <iframe>, see the HTML 4.0 spec.

<iframe name="livejournal"
scrolling="auto" height="400" width="460">
<a href="http://username.livejournal.com/">View my LiveJournal</a>

CGI Scripts

Basic CGI Script

You can write a CGI script (a program that runs on your server) to download your journal and then spit it back out to your clients. You could write a CGI script like this in any language, but by far the easiest language would be Perl, mostly because just about every hosting provider supports it.


The client will never see www.livejournal.com, because your server is actually the one that's downloading it.


This example uses the LibWWW module for perl, which you may need to install on your server, or have your admin do it.


use LWP::Simple;
print "Content-type: text/html\n\n";
print get('http://www.livejournal.com/customview.cgi' .

Server Side Includes and CGI

If you already have some existing content that you don't want to modify and you just want your LiveJournal inserted into an existing HTML document on your server everytime a client requests it, you can create the CGI script in the previous example and then place the example below into a server-parsed HTML document.


To get an HTML file to be server parsed, you usually have to name it .shtml, or set its execute bit; it depends on your webserver and how it's configured. In order to figure that out you might need to talk to your sysadmin.

<!--#exec cgi="/cgi-bin/livejournal.cgi" -->

Better Markup Language

If you're using BML on your server, you need to do two things in your document. First, you need to set the NOCACHE flag (example included), so that the visitor's browser doesn't store old states of the page in cache. Then you simply need to add in the given _CODE block somewhere on your page.

Since BML evaluates markup blocks returned from code blocks, you can include BML markup in your embedding style in order to make your embedded journal fit in with your BML scheme.


This uses the LibWWW module for Perl, which you may need to install on your server, or have your admin do it.


  use LWP::Simple;
  return get('http://www.livejournal.com/customview.cgi' .


Macromedia Flash

One of our users informed us that it is possible to have Flash download a list of variables to prefill into text elements in a Flash file. The formatting of these variable=value pairs are the same as in URLs. To accomodate this need, we provide a style which does this formatting for you. As an example, see the URL below.


Using fpassthru()

Contributed by: Bill Humpries

This method simply opens the journal URL, and then prints the content.


This method uses fopen() to open the journal URL, and then uses fpassthru() to pass the journal content to stdout.

$journalURL = "http://www.livejournal.com/".

if ($fh = fopen($journalURL,"r"))  {
} else {
    echo "<p>Unable to load journal.</p>\n";

Using fsockopen()

Contributed by: Elliot Schlegelmilch

This method is slightly different, and may work even if URL fopen wrappers aren't enabled on your server.


This method uses fsockopen() to open a network socket to the journal site, and then uses the HTTP protocol to request the journal's content. Given that it doesn't fail, it will simply fetch each line of the server's response.

$fp = fsockopen("www.livejournal.com", 80, &$errno, &$errstr, 30);
if($fp) {
    fputs($fp,"GET /customview.cgi?".
              "username=username&styleid=101 HTTP/1.0\n\n");
    while(!feof($fp)) {
        echo fgets($fp,128);

Using file()

Contributed by: Jay Cuthrell

This method is useful for those that want a line by line parse of their journal, with line number references.


This method uses the file() function to read in the journal content as a large array, and then it prints it back out line by line.

$page = "http://www.livejournal.com/customview.cgi".
$content = file($page);
$slurp = "";
while (list($foo,$bar) = each($content)) {
    $slurp .= $bar;
echo $slurp;

Using include()

Contributed by: Jon Parise

This simply includes the journal page inside of the PHP page.


This requires you have URL fopen wrappers enabled (they're on by default in PHP 4).

include "http://www.livejournal.com/customview.cgi".


Contributed by: Jeremy Tribby

Embedding your LiveJournal is easy with Python; just use the urllib class.

import urllib
u = urllib.open('http://www.livejournal.com/customview.cgi?username=username&styleid=101')
print 'Content-type: text/html\n\n'
print u.read()

Active Server Pages

Using the Microsoft.XMLHTTP component

Contributed by: Pavel Titov

This is an easy way to embed your journal using the Microsoft.XMLHTTP component and IIS.

    Response.Buffer = True
    Dim xml

    ' Create an xmlhttp object:
    Set xml = Server.CreateObject("Microsoft.XMLHTTP")
    ' Or, for version 3.0 of XMLHTTP, use:
    ' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

    ' Opens the connection to the remote server.
    xml.Open "GET",

    ' Actually Sends the request and returns the data:

    Response.Write xml.responseText

    Set xml = Nothing

Using PerlScript

Contributed by: Ansley Ingram

Here is how to embed your LiveJournal on your site using ASP and PerlScript.


Unfortuately, many WinNT hosting providers don't offer PerlScript. PerlScript is included in the ActivePerl installation for NT from ActiveState.

    use LWP::Simple;
    $Response->Write(get 'http://www.livejournal.com/customview.cgi?' .

Cold Fusion

Contributed by: billythebrick

Cold Fusion users can embed their journals as follows.


AOLServer .adp pages

Contributed by: jackal

You can embed your LiveJournal on your site using AOLServer's .adp pages.


This is not for people using AOL's Internet Access service; it is for people using the AOLServer web server.

 ns_puts "[ns_geturl http://www.livejournal.com/customview.cgi?username=username&styleid=101 ]"

<< Back to the embedding page