0
Welcome Guest! Login
0 items Join Now

ROCKETTHEME IS CLOSING ON JUNE 30, 2025. As a thank-you to our community, enjoy 50% off all themes with the promo code THANKYOU before we shut down. Read our Farewell Blog Post for more details.

Javascript In Article Not Executing

    • Joe Sonne's Avatar
    • Joe Sonne
    • Sr. Rocketeer
    • Posts: 147
    • Thanks: 0

    Javascript In Article Not Executing

    Posted 14 years 6 months ago
    • I'm not a Javascript guy so I don't really understand what I need to do to get some javascript working in an article in an older Rockettheme template (Chromatophore - Apr 08). [ I hope you don't consider this a template specific question - my apologies if it really is, I don 't intend to circumvent your forum rules.]

      I know that javascript works on the site because this simple script works in an article:
      <script type="text/javascript">
      document.write("Hello World!");
      </script>

      But the following more complex Javascript doesn't. I put this script into a plain .html document on the server and it executes, but when put into an article on the site it doesn't work. I'd appreciate any insight to get it working. Below is the full page html version.
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>404 Test</title>
      </head>
      <script type="text/javascript" language="Javascript">
       
      var tl=new Array(
       
      "This script doesn't work in an article using the Chromatophore theme.",
      "It works in a simple html page on the server.",
      "Any idea what needs to be done to get it working?",
      "Thanks!"
       
      );
      var speed=80;
      var index=0; text_pos=0;
      var str_length=tl[0].length;
      var contents, row;
       
      function type_text()
      {
        contents='';
        row=Math.max(0,index-6);
        while(row<index)
          contents += tl[row++] + '\r\n';
        document.textform.elements[0].value = contents + tl[index].substring(0,text_pos) + "_";
        if(text_pos++==str_length)
        {
          text_pos=0;
          index++;
          if(index!=tl.length)
          {
            str_length=tl[index].length;
            setTimeout("type_text()",1500);
          }
        } else
          setTimeout("type_text()",speed);
       
      }
      function MM_callJS(jsStr)
      {
      //v2.0
         return eval(jsStr)
      }
      //-->
      </script><body onload="type_text();">
            <center>
            <form name="textform">
            <textarea cols="70" rows="8" wrap="soft" readonly>
            </textarea>
      <br /><br /><a href="index.php" title="Home">HOME</a><br /><br />
            </form>
      </body>
      </html>
    • Take it to the edge.
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29363
    • Thanks: 956
    • Volunteer

    Re: Javascript In Article Not Executing

    Posted 14 years 6 months ago
    • Joe Sonne's Avatar
    • Joe Sonne
    • Sr. Rocketeer
    • Posts: 147
    • Thanks: 0

    Re: Javascript In Article Not Executing

    Posted 14 years 6 months ago
    • Thanks for your response. I usually just turn off the editor when putting this kind of code in an article. I think my problem is more what part of the code to use inside the article.

      Note - Edited to provide more information:

      If I insert all the code from <script type="text/javascript" language="Javascript"> to </script> it does not execute. I suspect that some of the code between the <body> tags such as
      <body onload="type_text();">

      is needed to trigger the script. I've tried using it a couple of different ways without success.
    • Take it to the edge.
    • Joe Sonne's Avatar
    • Joe Sonne
    • Sr. Rocketeer
    • Posts: 147
    • Thanks: 0

    Re: Javascript In Article Not Executing

    Posted 14 years 6 months ago
    • I suspect that the onload command is not in the right place when trying to trigger this when the article is loaded.

      Anyone have an idea?
    • Take it to the edge.
  • Re: Javascript In Article Not Executing

    Posted 13 years 6 months ago
    • I facing the same problem, anyone can help?
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29363
    • Thanks: 956
    • Volunteer

    Re: Javascript In Article Not Executing

    Posted 13 years 6 months ago
    • try one of those extensions that allow you to execute j-script code in articles and modules from the JED or the use the one I mentioned above.
    • Adamck's Avatar
    • Adamck
    • Elite Rocketeer
    • Posts: 546
    • Thanks: 2
    • Web Developer, IT Assistant, Graphics design, App Developer

    Re: Javascript In Article Not Executing

    Posted 13 years 6 months ago
    • Ive been using Flexi Custom Code module for adding Javascript and PHP to modules.
      You can then use the {loadposition ...} to get it into an article i guess :)

      Also some jQuery stuff conflicts with Mootools, just so your aware!
    • Kiss my RSS
  • Re: Javascript In Article Not Executing

    Posted 13 years 6 months ago
    • Hello mr. Henning,
      I'm using wordpress

      Hi Adamck,
      Actually i'm just an html/php newbie

      Can you all the expert tell me in detail?
      i really blank about it, hope you can help me.
      Thank you so much

      i also don't understand, i using javascript form calculator on the lower panel on my website (kaskusbay.com)
      its work, but when i use it on the sidebar /or pop up mode. it doesn't work at all, the question is, why?
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29363
    • Thanks: 956
    • Volunteer

    Re: Javascript In Article Not Executing

    Posted 13 years 6 months ago
    • Sorry,

      I'm not a wordpress guy. :-)
  • Re: Javascript In Article Not Executing

    Posted 13 years 6 months ago
    • Ok no prob mr. Henning, thx anyway
      Any wordpress guy here who can help my problem?

Time to create page: 0.085 seconds