Search code examples
jquerydatatablesforum

Trying to use javascript in a forum post


I'm making a post in a forum and I'd like to use a dataTable. I've added in the following to the top of my post:

<script type="text/javascript" src="http://www.datatables.net/release-datatables/media/js/jquery.dataTables.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>

However, when I go to add in the following, the $ get turned into &#36; (when I view the source of the post after it's posted):

<script>$(document).ready(function(){$('#wcw').dataTable({"sPaginationType":"full_numbers"});});</script>

I'm not sure if the $ is the problem as to why the table isn't being "transformed" or if it's because of trying to use the jquery scripts. Here's the page.


Solution

  • Most forums do not allow javascript in posts due to security reasons. Such attacks in userinput which is later shown on the page to public are called XSS-Attacks (cross-site scripting attacks). You can try to share the table on a site which is specialy made for this usecase and post a link to it in the forum.

    EDIT:

    I saw that <script>-tags are allowed on the site. You can then try to use jQuery in noconflict-mode.

    Try following:

    <script>jQuery.noConflict(); jQuery(document).ready(function(){jQuery('#wcw').dataTable({"sPaginationType":"full_numbers"});});</script>