Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
7374 Переглядів

I Want to add a Javascript code in website template, but in ONE specific template...

Example:

I have this template that is rendered by the controller in my website:

"""

<template id="solici" name="Form">
<t t-call="website.layout">
<div class="container">
<iframe width="1100"
id="pm_iframe"
class="embed-responsive-item"
frameborder="0"
t-attf-src="{{pm_iframe}}"/>
</div>
</t>
</template>

"""

I want to manipulate the dom with this iframe to do something like this:

"""

var iframe = document.getElementById("myIframe");



// Adjusting the iframe height onload event

iframe.onload = function(){

iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';

"""

Аватар
Відмінити
Найкраща відповідь

Hello,

For adding javascript in template simply you need to add the piece of code in <script> </script>tag 

In your case:

<template id="solici" name="Form">

    <t t-call="website.layout">

         <div class="container">

            <iframe width="1100"

                    id="pm_iframe"

                    class="embed-responsive-item"

                    frameborder="0"

                    t-attf-src="{{pm_iframe}}"/>

        </div>


<script>

var iframe = document.getElementById("myIframe");

// Adjusting the iframe height onload event

iframe.onload = function(){

    iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';

</script>

    </t>

</template>

Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
лип. 20
4033
1
груд. 20
5050
1
бер. 22
4309
2
вер. 21
7495
1
трав. 20
3970