Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sandbox Javascript

    I have attached a html code containing javascript. It needs to be Sandboxed. I would appreciate being shown how to do this within the rules below.

    The wsywig editor rules are:
    You can edit your site with HTML, CSS, and Javascript; however, Weebly does not support building your site with server side languages, such as PHP or ASP. We also do not currently offer database access. This is not likely to change in the near future.
    Standard, validated javascript that uses a sandbox for stability with other code can be inserted into the Custom HTML Element.

    Cheers,

    Jeff
    Attached Files Attached Files

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    I think you can generally insert any kind of script, but if you don't "sandbox" it, it might interfere with other code and might make the page unstable.

    The easiest way to stop your script from cluttering the global namespace and thus from interfering with other scripts, is to wrap it with
    Code:
    (function() {
       // your code here
    })();
    This is a self-calling anonymous function that will create its own scope.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,461
    Thanks
    11
    Thanked 600 Times in 580 Posts
    there is a sandbox attrib in html5. you can place restrictions on the iframe activity like turning on/off cookies, js, history, etc...
    my site (updated 2014/10/20)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.3, IE11:9.2, IE9:2.7, IE10:2.6, FF:16.8, CH:47.5, SF:7.8, NON-MOUSE:37%


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •