Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • JME 14 posts 61 karma points
    Jul 31, 2014 @ 23:50
    JME
    0

    Want to use a javascript function with TinyMCE and need help

    I want to use this simple javascript function to hide and unhide divs on my page.  The idea is that a user can have an introductory paragraph on a topic and, using the word more linked to the javascript function, can allow the page to display or hide the hidden div that contains more detail on the topic.

    Here is the javascript function code:

     <script type="text/javascript">
     function (divID) {
     var item = document.getElementById(divID);
      if (item) {
      item.className=(item.className=='hidden')?'unhidden':'hidden';
      }
     }
     </script> 

    In the RTE the user would put in their intro paragraph with the linked more :

    <a href="javascript:unhide('detail1');">more</a>

    and have their detail paragraphs in a div with the class of detail1.

    This lets an otherwise lengthy and text driven page display more eloquently and does not require pop-ups, new pages or links to pdf's to accomplish.

    Any suggestions?

     

  • André Nøbbe Christiansen 10 posts 71 karma points
    Aug 01, 2014 @ 01:26
    André Nøbbe Christiansen
    0

    I think i would make a macro for the RTE for this functionality, where you can put in the hidden text. 

  • JME 14 posts 61 karma points
    Aug 01, 2014 @ 05:19
    JME
    0

    The problem is the rte is not letting me put in the more link with the javascript call in the link.  When I try, the rte strips out the javascript call in the href.  I would like to have this as re-usable code so whenever the user has a long paragraph they want to hide/unhide they can use it but I am stuck as I see no way to create the "more" link with the javascript call in it.

  • André Nøbbe Christiansen 10 posts 71 karma points
    Aug 01, 2014 @ 12:18
    André Nøbbe Christiansen
    0

    I think it is easiest if the "more" link is made in the macro also.
    Do you write in xslt of Razor? Then i could write an example.

  • JME 14 posts 61 karma points
    Aug 01, 2014 @ 16:29
    JME
    0

    I am new to all of this (I previously worked in coldfusion) so I am investigating xslt and Razor but have no prior experience.  The problem I run into - when I put the  more in the macro - is that the javascript call in the href causes the macro to error when it is brought in to the rte.  If i replace the javascript call in the href (I just plugged in. a link to cnn.com  instead of the javascript call) then the macro is pulled in without error.

    I know I can create a special template and run the page that way - but this does not give the user the ability to use the hide/unhide function.  I am hoping someone has an idea on how to solve this so that I can get this working.  It was a nice feature on the coldfusion versions of our sites. 

  • James Hayward 17 posts 37 karma points
    Sep 07, 2014 @ 05:28
    James Hayward
    0

    I'm having the same type of issue - Using : Umbraco v6.1.2 Expertise Level: Beginner Umbraco

    Want to embed some javascript (web form) onto our contact us page. The trick is that I actually want to float the javascript into position so that it sits in position on the page. However when I place the javascript into its place it gets stripped out. What is correct protocol for placing javascript into a single page?

    Is this right? I managed to place my (Google anayltics / social media add this) java code into the template which is working fine. But have been reading I could have placed it in correctly, as I just pasted the code into the header. what is the correct protocol to placing javascript into umbraco templates?

    Cheers James

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 22, 2016 @ 23:55
    Marcin Zajkowski
    0

    I know that this is an old topic, but just provided a solution for another Umbracian solving exactly this problem.

    Feel free to check it there: https://our.umbraco.org/forum/using-umbraco-and-getting-started/77417-cannot-insert-a-mailto-link-in-the-rich-text-editor#comment-247580 :)

Please Sign in or register to post replies

Write your reply to:

Draft