Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1271042

    Hi,

    i’m trying to embed some js code via code block modul in my site.

    It is for a booking mask to make the window responsive.

    <script type=’text/javascript’>
    var eventMethod = window.addEventListener ? “addEventListener” : “attachEvent”;
    var eventer = window[eventMethod];
    var messageEvent = eventMethod == “attachEvent” ? “onmessage” : “message”;

    eventer(messageEvent,function(e) {
    if (e.data.indexOf(‘resize_request::’) != -1) {
    var height = e.data.replace(‘resize_request::’, ”);
    document.getElementById(‘requestFrame’).style.height = height+’px’;
    }
    } ,false);
    </script>

    but it doesn’t change anything. Also i get a this massege in the code block window: “Warning: Characters <,>,[,] might break ALB backend or frontend. Read more if you want to use them.”

    It also doesen’t work if i copy the the code in my childs functions.php file.

    Any idea what i can do?

    #1271914

    Hey Stefan,
    Sorry for the late reply and thanks for showing your script, I tested this on my localhost and got the error:
    Uncaught SyntaxError: Invalid or unexpected token but I couldn’t identify the unexpected token.
    I’m not following what your script is trying to do, can you explain further?

    Best regards,
    Mike

    #1272341

    Hi Mike,
    it should resize the height of the embeded iframe according to the length of the content.

    #1272408

    Hi,
    Are you sure this script is complete? It seems like “requestFrame” should be declared?
    A script in the code block element should work correctly when it is within “script” tags as you have above, we often use this method. While you will see the “character” warning, the tags do work correctly in the element. For example you can try this script in a code block element and an alert will show on page load:

    <script type="text/javascript">
    document.onreadystatechange = function(){
        if(document.readyState=='loaded' || document.readyState=='complete')
            alert('Page Loaded');
    }
    </script>

    I’m not sure why your script is not working, but I suspect that it is the script and not the element, since it is not working in your functions.php either, but I’m not sure as I use jQuery more than Javascript.
    You may need to enlist the help of a freelancer to debug your script as this is outside the scope of our support.
    I would also ensure that you are not using any caching, minifying, or compression with plugins and theme options, sometimes a plugin will minify minified files, and it is this second minification that breaks some scripts.

    Best regards,
    Mike

    #1272654

    HI Mike,

    now it works :-) the problem was the setting script compressing in performance settings in my theme options

    #1272717

    Hi,
    Glad to hear that you have sorted this out, we will close this now. Thank you for using Enfold.

    For your information, you can take a look at Enfold documentation here
    For any other questions or issues, feel free to start new threads in the Enfold forum and we will gladly try to help you :)

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘embed som js conde’ is closed to new replies.