Page 1 of 1

How do I use Javascript in content?

Posted: Wed Jan 10, 2007 6:32 pm
by outdoorxtreme1
I want to use this line in the content of one of my pages

Code: Select all

<__script__ LANGUAGE="Javascript" SRC="uploads/images/neoh2007/NEOHtipsearch.js"></__script>
I tried using the {literal} {/literal} tags around the code like this

Code: Select all

{literal}<__script__ LANGUAGE="Javascript" SRC="uploads/images/neoh2007/NEOHtipsearch.js"></__script>{/literal}
but when I view the source code all I see is

Code: Select all

{literal} {/literal}
and no script line

Ho can I use this line in content for a page?

Re: How do I use Javascript in content?

Posted: Wed Jan 10, 2007 8:15 pm
by jmcgin51
paste
{literal}{/literal}
into your source code (HTML view)

when you view the WYSIWYG, you'll just see the {literal}{/literal} tags, but the JS will be there in the source.

Re: How do I use Javascript in content?

Posted: Fri Jan 12, 2007 7:34 pm
by outdoorxtreme1
I was able to get it to work but if I go and edit something else in the page content at a later date and submit my scripts are gone. Do I have to re add them every time I submit?

Re: How do I use Javascript in content?

Posted: Fri Jan 12, 2007 7:52 pm
by jmcgin51
no, this shouldn't be necessary.  CMSMS should treat the Javascript and {literal} tags just like any other text on the page, and shouldn't delete them automatically.  What version of CMSMS are you using?

Re: How do I use Javascript in content?

Posted: Fri Jan 12, 2007 7:55 pm
by outdoorxtreme1
1.0.2 "Maui"

Re: How do I use Javascript in content?

Posted: Fri Jan 12, 2007 8:05 pm
by outdoorxtreme1
I have the following content in my page:

Code: Select all

<br />
<table cellspacing="5" cellpadding="0" width="558" border="0">
    <tbody>
        <tr>
            <td valign="top" width="304">
            <table cellspacing="0" cellpadding="0" border="0">
                <!-- NOTE: START RECREATION INFO -->
                <tbody>
                    <tr>
                        <td width="62"><img style="LEFT: 5px; POSITION: relative" alt="" src="uploads/images/neoh2007/icons_07.gif" /></td>
                        <td valign="top"><img alt="" border="0" src="uploads/images/neoh2007/header_05.gif" /></td>
                    </tr>
                    <tr>
                        <td align="left" colspan="2">
                        <table cellpadding="4" width="290">
                            <tbody>
                                <tr>
                                    <td valign="top"><a class="linksBold" href="/index.php?page=MCLat">ATVing</a><br />
                                    <a class="linksBold" href="/index.php?page=MCLbi">Backpacking</a><br />
                                    <a class="linksBold" href="/index.php?page=MCLmls">Bicycling</a><br />
                                    <a class="linksBold" href="/index.php?page=MCLcm">Camping</a><br />
                                    <a class="linksBold" href="/index.php?page=MCLfh">Fishing</a><br />
                                    <br />
                                    </td>
                                    <td valign="top"><a class="linksBold" href="/index.php?page=MCLfh">Geocaching</a><br />
                                    <a class="linksBold" href="/index.php?page=MCLps">Kayaking</a><br />
                                    <a class="linksBold" href="/index.php?page=MCLcm">Rappelling</a><br />
                                    <a class="linksBold" href="/index.php?page=MCLws">Skiing</a><br />
                                    <a class="linksBold" href="/index.php?page=MCMspi">Special Interests</a><br />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        </td>
                    </tr>
                    <!-- NOTE: END RECREATION INFO -->
                    <tr>
                        <td colspan="2"><hr color="#000066" size="2" />
                        </td>
                    </tr>
                    <!-- NOTE: START PRODUCT REVIEW -->
                    <tr>
                        <td><img alt="" src="uploads/images/neoh2007/icons_18.gif" /></td>
                        <td valign="top"><img style="POSITION: relative; TOP: 10px" alt="" border="0" src="uploads/images/neoh2007/header_18.gif" /> <center>
                        <div style="RIGHT: 22px; POSITION: relative; TOP: 14px"><a class="linksBold" target="_blank" href="http://www.gossamergear.com/cgi-bin/gossamergear/Mariposa-Standard.html">Mariposa Backpack <br />
                        By Gossamer Gear<br />
                        <br />
                        </a></div>
                        </center></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        <table cellspacing="0" cellpadding="0">
                            <tbody>
                                <tr>
                                    <td><a href="http://www.gossamergear.com/cgi-bin/gossamergear/Mariposa-Standard.html"><img alt="Mariposa Ultralight Backpack by Gossamer Gear" width="100" border="0" src="uploads/images/neoh2007/Mariposa-90.jpg" /></a></td>
                                    <td> </td>
                                    <td width="175">
                                    <p style="FONT-SIZE: 10px; FONT-FAMILY: Arial, Helvetica, sans-serif">The Mariposa Ultralight revolutionizes ultralight backpacking, with an incredible array of important features, but a maximum weight of just over a pound! <a class="link10pt" target="_blank" href="http://www.gossamergear.com/cgi-bin/gossamergear/Mariposa-Standard.html">Learn More</a></p>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        </td>
                    </tr>
                    <!-- NOTE: END PRODUCT REVIEW -->
                </tbody>
            </table>
            </td>
            <td valign="top" align="center" width="254">
            <table cellspacing="0" cellpadding="0" width="242">
                <!-- NOTE: START NEW TRIP LISTINGS -->
                <tbody>
                    <tr>
                        <td colspan="3"><img alt="" border="0" src="uploads/images/neoh2007/newlistings2_01.gif" /></td>
                    </tr>
                    <tr>
                        <td width="10" background="uploads/images/neoh2007/newlistings2_02.gif"> </td>
                        <td width="213" bgcolor="#e5eaee">
                        <table cellspacing="0" cellpadding="2" width="100%" border="0">
                            <tbody>
                                <tr>
                                    <td valign="top" align="center" colspan="3" height="20"><span style="FONT-WEIGHT: bold; FONT-SIZE: 14px; COLOR: #000066; FONT-STYLE: normal; FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-VARIANT: normal; font-size-adjust: none">NEW TRIP LISTINGS</span></td>
                                </tr>
                                <tr>
                                    <td><img alt="" src="uploads/images/neoh2007/pushpin.gif" /></td>
                                    <td align="left"><a class="linksBold" target="_blank" href="http://www.neohoutdoors.com">Clarion River</a></td>
                                </tr>
                                <tr>
                                    <td colspan="3" height="10"> </td>
                                </tr>
                            </tbody>
                        </table>
                        </td>
                        <td width="19" background="uploads/images/neoh2007/newlistings2_04.gif"> </td>
                    </tr>
                    <tr>
                        <td colspan="3"><img alt="" border="0" src="uploads/images/neoh2007/newlistings2_07.gif" /></td>
                    </tr>
                </tbody>
                <!-- NOTE: END NEW TRIP LISTINGS -->
            </table>
            <table cellspacing="0" cellpadding="0">
                <!-- NOTE: START GO OUTSIDE AND HAVE FUN GUIDE -->
                <tbody>
                    <tr>
                        <td colspan="2"> </td>
                    </tr>
                    <tr>
                        <td colspan="3"><img height="10" alt="" width="254" src="uploads/images/neoh2007/neoh_41.gif" /></td>
                    </tr>
                    <tr>
                        <td width="10" background="uploads/images/neoh2007/neoh_43.gif"> </td>
                        <td valign="top" width="236"><img alt="" border="0" src="uploads/images/neoh2007/header_12.gif" />
                        <table cellspacing="0" cellpadding="5" border="0">
                            <tbody>
                                <tr>
                                    <td valign="top"><img alt="" src="uploads/images/neoh2007/icons_11.gif" /></td>
                                    <td align="center">
                                    <form action="ASOmain.asp?Option=MTP" method="post">
                                        <input type="hidden" name="fWhichTip" value="x" /> <select class="select" onchange="SendForm2(form,'Tips',this)" name="fTips">
                                        <option value="" selected="selected">Tips, Guides, FAQs</option>
                                        <option value="">------------------------</option>
                                        {literal}<__script__ LANGUAGE="Javascript" SRC="uploads/images/neoh2007/NEOHtipsearch.js"></__script>{/literal}

</select> <center><img height="10" alt="" src="uploads/images/neoh2007/spacer.gif" /></center><select class="select" onchange="SendForm2(form,'Links',this)" name="fLinks">
                                        <option value="" selected="selected">Other Resources</option>
                                        <option value="">------------------------</option>
                                        {literal}<__script__ LANGUAGE="Javascript" SRC="uploads/images/neoh2007/NEOHlinksearch.js"></__script>{/literal}
</select>
                                    </form>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        </td>
                        <td width="8" background="uploads/images/neoh2007/neoh_45.gif"> </td>
                    </tr>
                    <tr>
                        <td colspan="3"><img height="10" alt="" width="254" src="uploads/images/neoh2007/neoh_46.gif" /></td>
                    </tr>
                </tbody>
                <!-- NOTE: END GO OUTSIDE AND HAVE FUN GUIDE -->
            </table>
            <table cellspacing="0" cellpadding="0" width="254" border="0">
                <!-- NOTE: START OUTDOOR TIP -->
                <tbody>
                    <tr>
                        <td colspan="2"> </td>
                    </tr>
                    <tr>
                        <td align="center" width="62"><img alt="" src="uploads/images/neoh2007/icons_20.gif" /></td>
                        <td valign="top"><img style="POSITION: relative; TOP: 6px" alt="" border="0" src="uploads/images/neoh2007/header_21.gif" /> <center>
                        <div style="RIGHT: 5px; POSITION: relative; TOP: 10px"><a class="linksBold" href="http://www.adventuresportsonline.com/wintereye.htm">Winter Eyewear Tips</a> <br />
                        <br />
                        </div>
                        </center></td>
                    </tr>
                    <tr>
                        <td align="left" width="275" colspan="2">
                        <p style="FONT-SIZE: 10px; FONT-FAMILY: Arial, Helvetica, sans-serif">Sunglasses & Goggles Buying Tips: -- <a class="link10pt" href="http://www.neohoutdoors.com/wintereye.htm">Read More</a></p>
                        </td>
                    </tr>
                </tbody>
                <!-- NOTE: END OUTDOOR TIP -->
            </table>
            </td>
        </tr>
    </tbody>
</table>
I have 2 {literal} tags could that be the problem? It seem to work the first time I save it. If I go back in and edit something in the source cose and save it again my javascripts arent working.

Re: How do I use Javascript in content?

Posted: Fri Jan 12, 2007 8:07 pm
by Lauenborg
Hi There

I also have a problem with a javascipt in one of my content pages. I have a form that I used in an old website(before CMS) and to that form I have a "java validation script" to validate the fields..

I have tried to insert with the "literal" tags in the actual page, but it wont validate...Maybe you have and idea of what to do..?

see the script here:
Best regards Bo

{literal}

function validering()
 {
 error = 0;
 
 if((document.forms[0].hvordanfandtdu.value=='') && (error==0))  
 {
   alert('Husk at vaelge hvordan du fandt MindTrack Coaching!');
   document.forms[0].hvordanfandtdu.focus();
   error = 1;
 }

if(error == 0)
 document.forms[0].submit();
 }

// Slut -->
{/literal}
jmcgin51 wrote: paste
{literal}{/literal}
into your source code (HTML view)

when you view the WYSIWYG, you'll just see the {literal}{/literal} tags, but the JS will be there in the source.

Re: How do I use Javascript in content?

Posted: Fri Jan 12, 2007 8:15 pm
by outdoorxtreme1
The tags are there but the javascript doesn't work on my webpage.

Re: How do I use Javascript in content?

Posted: Mon Jan 15, 2007 8:05 pm
by outdoorxtreme1
I am having a heck of a time trying to get the following javascripts to work in my page content. Can someone please help me. Could it be the wysiwyg editor I am using? I currently have FCKeditor

I am trying to get the following to work in a page content:

Code: Select all

                        <form action="index.php?page=" method="post">
                            <input type="hidden" name="fWhichTip" value="x" /> <ins><select class="select" onchange="SendForm2(form,'Tips',this)" name="fTips">
                            <option value="" selected="selected">Tips, Guides, FAQs</option>
                            <option value="">------------------------</option>
                            {literal}<__script__ LANGUAGE="Javascript" SRC="/uploads/images/neoh2007/NEOHtipsearch.js"></__script>{/literal}
                            </select> <center><img height="10" alt="" src="uploads/images/neoh2007/spacer.gif" /></center><select class="select" onchange="SendForm2(form,'Expert',this);" name="fAsk">
                            <option value="" selected="selected">Ask the Expert</option>
                            <option value="">------------------------</option>
                            <option value="ask-advrace-expert.htm">Adventure Racing</option>
                            <option value="askpaddleexpert.htm">Paddlesports</option>
                            <option value="askbikeexpert.htm">Road/Mountain Bike Touring and Racing</option>
                            <option value="asktheexpertgear.htm">Outdoor Gear</option>
                            <option value="askfitexpert.htm">Fitness</option>
                            <option value="askskiexpert.htm">Skiing</option>
                            <option value="askfishexpert.htm">Fishing</option>
                            </select> <center><img height="10" alt="" src="uploads/images/neoh2007/spacer.gif" /></center><select class="select" onchange="SendForm2(form,'Links',this)" name="fLinks">
                            <option value="" selected="selected">Other Resources</option>
                            <option value="">------------------------</option>
                            {literal}<__script__ LANGUAGE="Javascript" SRC="/uploads/images/neoh2007/NEOHlinksearch.js"></__script>{/literal}
</select> </ins>
                        </form>

Re: How do I use Javascript in content?

Posted: Fri Jan 19, 2007 3:59 pm
by Pierre M.
May be you can put your literal/JS in a global content bloc or custom tag ?

And remember that JS never works on user agents like mine (with noscript plugin) or corporate ones (filtering firewalls).
(edit : I mean no site should rely on it to work)

PM