Forum: Radiant CMS JavaScript in a Page?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Saji Njarackalazhikam H. (Guest)
on 2007-05-23 08:21
(Received via mailing list)

I would like to insert some javascript commands to navigate among a set
of images. I am thinking of constructing an array of image files, for

Panel1=new Array(
thisPlot = 2
plotLen=Panel1.length - 1

Later within the body, I would change between images using -

<A Href="javascript:processPrevious()">&laquo;</A> &nbsp;
     <A Href="javascript:processNext()">&raquo;</A>

The array Panel1 is page-specific, so I cannot insert it into a Layout
I am not sure if I can insert this within a Page.

Any help and tips would be much appreciated.


Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 
Chris P. (Guest)
on 2007-05-23 16:38
In a site that I am building, I have a similar requirement.  There are
standard, site-wide css and javascript files that are included in my
layout but I also have page specific javascript or css that occasionally
needs added to the <head> section.

I solve it by including the following in my layout:
    <r:if_content part="css"><r:content part="css"/></r:if_content>
    <r:if_content part="js"><r:content part="js"/></r:if_content>

Then, in the appropriate pages, I create a new page part named "css" or
"js" and put in my code in there.

The cool thing about this method is that I can declare inline javascript
or css like:
    <style type="text/css" media="screen">
      #mainPic {display:none}

or I can include an external file like:
    <script src="/my/special/script.js" type="text/javascript"></script>

Saji H. (Guest)
on 2007-05-24 06:11
(Received via mailing list)
thanks a lot, Chris. this will allow me to replace images using
buttons in a page i am using, instead of putting one page per image.
Oliver C. (Guest)
on 2007-05-28 15:23
Hi -

Thanks for the useful information about how to add JavaScript to a page.

I know it's not quite on the topic of RoR, but I need a little bit of
help with my JavaScript.

My HTML is as follows:

<ul id="nav">
  <li id="nav-welcome"><a href=""
title="Return to the home page"Welcome</a></li>
  <li id="nav-blog"><a href="/blog/" title="Read the latest blog
  <li id="nav-contact"><a href="/contact/" title="Contact information
for Oliver C.">Contact</a></li>

What I want to do is apply the class "selected" to certain links using
JavaScript. The purpose of this is to show waht page you are currently

The JavaScript I currently have is this:

<script type="text/javascript">

However, this only applys the class of "selected" to the <li> item. How
to use the getElementById function to select the actual hyperlink?

Many thanks in advance!
Matt Parrish (Guest)
on 2007-05-28 18:22
(Received via mailing list)
Hi Oliver,

You have two typical options in this case.  The first is to give your
<a> element an id, just like you did for the <li> element.  Then you
could use that id in your javascript.  The other method, though, is
probably what you want.  You could keep your html and javascript the
way it is, and modify your css (I assume you're using css).  So
instead of your css looking like

.selected {
     #some styles

you could have

.selected a {
     # some styles for hyperlink

This way your styling the hyperlink inside of an element with
className "selected"

Hope that helps,
This topic is locked and can not be replied to.