py4web iframe js not working

71 views
Skip to first unread message

mauri...@gmail.com

unread,
Jun 29, 2022, 1:28:47 PM6/29/22
to py4web
I'm still porting from web2py to py4web
This code works well in web2py (parent and iframe) but only in parent page on py4web.
Is there a way to make it work in iframe?

<html>
  <style type="text/css">
    ul ::-moz-focus-inner {
          border: 0;
        }

        ul:active, ul:hover {
          outline: none
        }
        ul {
          outline: none;
        }
        ul :focus {
          outline: none;
        }
        ul li{
            width: auto;/*150px !important;*/
            font-size: 0.7em;
            font-weight: 600;
            padding: 7px 7px 7px;
            margin-top: 7px;
            margin-bottom: 7px;
            margin-right: 7px;
            margin-left: 7px;
            text-align: center;
            display: inline-block;
            cursor: pointer;
            border:#D9383B solid 1px;
            border-radius: 15px;
            background-color: #D9383B;
            color: white;/*#38D9D6;*/
        }
        ul {
            margin-top: 7px !important;
            /*margin-left: 35px;*/
      display: none;
            border: none;
            height: 30px !important;
            width: auto;
            background-color: transparent;
            cursor: pointer;
        }    
 
        .test_wrapper {
            height: 100px;
            overflow-x: scroll;
            overflow-y: hidden;
            width: auto;/*96vw;*/
            background-color: white;
        }
  </style>
<body>
  <h1>Demo: JavaScript Variables </h1>
  <div class="test_wrapper">
        <div class="test_row">
            <ul id="tesla"></ul>
        </div>
    </div>
 
  <script type="text/javascript">
        var tasks = ['error', 'referrals', 'advertise', 'tesla',]
        if (tasks[3] == 'tesla' && Array.isArray(tasks)) {
          alert('cool');
          var link_tesla = "https://www.tesla.com"
          var a = document.createElement("a_err");
          var ulist = document.getElementById("tesla");
          var newItem = document.createElement("li");
          a.textContent = "Read ModelX Here";
          newItem.appendChild(a);
          ulist.appendChild(newItem);
          $("a_err").on("click", function() {
              window.open(link_tesla, "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=500,height=600");
              });
        }
    </script>
</body>
</html>

Massimo

unread,
Jun 30, 2022, 2:20:47 AM6/30/22
to py4web
Sorry do not understand. Do not see and iframe nor any py4web code here, therefore I am not sure what you are trying to do.

mauri...@gmail.com

unread,
Jul 1, 2022, 7:06:42 AM7/1/22
to py4web
Hello,
Sorry I couldn't get a chance to edit nor reply on time.
Its a nested iframe.
First html has some animation e.g. "dot-fallong" and loads another page while the animation plays:
Parent page:
<iframe class='responsive-iframe' id='if1' onLoad='RIframeLoad();' marginwidth='0' marginheight='0' border-radius='5px' frameBorder='0' src='[[=URL('get_answer')]]'></iframe>

<script type="text/javascript">
        function RIframeLoad() {
            alert('Done');
//this js works on this page
        }
</script>

1st child page(get_answer.html):
This loads another page with data.There are some iterations in imported .py files which access db files hence some delays(Though in ms).
[[extend 'layout.html']]

<!--Load results with dot-falling animation before-->
<ajax-component id="component_1"  url="[[=URL('get_result')]]">
    <blink class="dot-falling"></blink>
</ajax-component>

2nd child iframe(get_result.html)
Gets the data posted. This is where the js action is silent.

Massimo

unread,
Jul 2, 2022, 11:49:20 AM7/2/22
to py4web
I am sorry. Still do not have enough information but maybe try to load the content of the iframe as mail page and check if it works as you expect.
Reply all
Reply to author
Forward
0 new messages