Jump to:

23364 Posts in 18125 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Javascript in new Page

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 356 Views
  • Samy
    Avatar
    Community Member
    2 Posts

    Javascript in new Page Link to this post

    Hello people.

    Im here to report a problem or to get some help to understand how to use javascript code in a new page.

    I put my code in html page:
    <img src="/image.gif" onclick="startGateway('155891');" />

    And this under the html code.
    <script type="text/javascript" src="/gateway/mygate.php?id=4e2b7a3945426d416d786c7542355776"></script>

    But when i save and publish my site and i go in the page and click the image, i do not see any script opening.

    PS: I got this problem with AdSense script too.

    Thanks

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: Javascript in new Page Link to this post

    You'll have to explain how you are putting this in your page. In the template? In a content window in the CMS admin?

    The latter isn't really the place for this as TinyMCE will strip certain tags out when you save as a security measure. There are ways to allow it in code. But if this is your site, what you are doing here is better off in the template.

    What does the source code of this section end up looking like on the frontend?

  • Samy
    Avatar
    Community Member
    2 Posts

    Re: Javascript in new Page Link to this post

    I put the code on content window in the CMS admin page. The source of this code open a table where you have to complete a survey.

    How can i allow this code, or where i have to put it if i want to use it in pages?

  • kiwidude95
    Avatar
    Community Member
    24 Posts

    Re: Javascript in new Page Link to this post

    Maybe try using jQuery? This will also allow you to modify any script changes on the external javascript file rather than on individual items like /image.gif

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: Javascript in new Page Link to this post

    Is there any reason why you are not putting this into your template file?

    The HTML Editor window is not really the place for JavaScript unless you extend it. It strips out some HTML tags because giving users the ability to inject JavaScript is a security concern.

    If you want to allow JavaScript to be entered into the editor, you'll need to search for TinyMCE. That's what the editor is and it's a third party app.

    356 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.