WordPress.org

Ready to get started?Download WordPress

Forums

Inserting JavaScript in html editor gets messed up (3 posts)

  1. edmitch
    Member
    Posted 8 years ago #

    I put the following JavaScript into an HTML file, copy it the server, and everything works just fine:
    <script language="JavaScript" type="text/javascript">
    addPTViewerParameter("file","IMG_0085_0360.jpg");
    addPTViewerParameter("fov","92");
    addPTViewerParameter("wait","controlimages/wait.gif");
    addPTViewerParameter("auto",".25");
    InsertPTVApplet("viewer",640,500);
    </script>

    In WordPress, I attempt to enter the same text into the HTML editor as a post (TinyMCE is turned off) and this is what ends up in the file that is eventually displayed (this is what shows up in the page source after fetching the page from WordPress):

    <script language="JavaScript" type="text/javascript"><br />
    addPTViewerParameter(”file”,”IMG_0085_0360.jpg”);<br /> addPTViewerParameter(”fov”,”92″);<br />
    addPTViewerParameter(”wait”,”controlimages/wait.gif”);<br />
    addPTViewerParameter(”auto”,”.25″);<br />
    InsertPTVApplet(”viewer”,640,500);<br />
    </script>

    Note the conversion of quotes into ” and the insertion of <br/> throughout the JavaScript.

    Is there any way to turn off this conversion and insertion of <br>? Remember, this is all being done in the html editor with TinyMCE disabled for this user (me).

    Thanks,

    Ed
    (I'm not sure what a 'backticks' is here so its possible my code example will be turned to mush in the above.)

  2. edmitch
    Member
    Posted 8 years ago #

    Well, it didn't display as I intended. In the 2nd set of Javascript the quotes should all be displayed as "& # 8 2 2 1;" without the spaces. Even though this translates back to quotes here (and elsewhere) if I copy this code directly to the original HTML file, it no longer works.

    I'd just like to keep my javascript exactly as I originally wrote it without conversion.

  3. edmitch
    Member
    Posted 8 years ago #

    After further thought, I assume the html editor eliminates all quotes for storage as a text string. Too bad.

    I suppose I might write some php code that could insert the necessary script.

Topic Closed

This topic has been closed to new replies.

About this Topic