Parameters not sent to embedded HTML

Workarounds and usability notes.

Parameters not sent to embedded HTML

Postby John Robin Dove » Sun Jun 26, 2016 11:38 am

Hi Clifton,

I'm stuck and I don't understand why. I have 2 functions in the script section of my embedded HTML document accessed via pgGotoURL:
Code: Select all
function goFullScreen(objNo) {
var X = window.screen.availWidth;
var Y = window.screen.availHeight;
var element =  document.getElementById("m" + objNo);
// alert (element.offsetLeft + "," + element.offsetTop);
element.style.width = X;
element.style.height = Y;
//     if (objNo > 1) {
//     element.style.left = "0px";
//     element.style.top = "0px";
//     }
};

function restoreSize(objNo) {
alert(objNo);
var element =  document.getElementById("m" + objNo);
element.style.width = 620;
element.style.height = 460;
//     if (objNo > 1) {
//     element.style.left = "0px";
//     element.style.top = "0px";
//     }
element.style.left = 8;
element.style.top = 8;
};


In the TB part I am using 2 global variables: total and userNo. The values are integers for example 1 or 2. At first neither of my embedded functions worked. When I included an alert they both returned undefined. I tried this:
total = total * 1, userNo = userNo * 1 to make sure they were being defined as integers. Predictably it didn't make any difference. I then tried sending them as part of a local array variable myArray[ 0 ] = total. This 'cured' the goFullScreen function. objNo is now being received as an integer as planned. But it won't work with the other function. Whatever I do objNo remains undefined in the restoreSize function. Any ideas please? I really can't think of anything else to do.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Parameters not sent to embedded HTML

Postby Clifton » Sun Jun 26, 2016 4:43 pm

Are you using pgExecuteRemote() to run and send data to the functions in your HTML document?
This is very important to ensure variable conversion and consistency

The PowerPac popup help windows indicates you can send parameters in a couple of different ways:
  1. Set argArray to a comma-separated string. The PowerPac will build the argArray from the string where each stack item is a parameter that should be sent to the function. In this case strings as numbers will be converted to numbers.
  2. Set argArray to an Actions Editor array where each index of the array is parameter that should be sent to the function.
      In this case, if your function expects an array as one of its parameters, then set argArray[#] = [yourArray]
Consider this example:
    Let's embed this HTML document into a field . . . (notice we have defined two functions which change the content of an object with id="ToolBook"
    Code: Select all
    <!doctype html>
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <meta name="generator" content="PSPad editor, www.pspad.com">
      <title></title>

      <style>
        body { background-color: #DBDBB3; font-size:11pt; font-family: Tahoma, Arial; }
        div, p { font-size: inherit; line-height: 1.42em; }
        .data { color: #3B776D; }
      </style>
     
      <script>
        function mySample(arg1, arg2) {
          var el = document.getElementById('ToolBook');
          if (el) {
            el.innerHTML =  "This Remote Window processed:<br>";
            el.innerHTML += "Custom Function: <span style='color:blue;'>mySample(arg1, arg2)</span><br>";
            el.innerHTML += "<b>arg1</b> received as " + typeof arg1 + " content: <span class='data'>" + arg1 + "</span><br>";
            el.innerHTML += "<b>arg2</b> received as " + typeof arg2 + " content: <span class='data'>" + arg2 + "</span>";
          }
        }
        function mySample2(arg) {
          var el = document.getElementById('ToolBook');
          if (el) {
            el.innerHTML =  "This Remote Window processed:<br>";
            el.innerHTML += "Custom Function: <span style='color:purple;'>mySample2(arg)</span><br>";
            el.innerHTML += "<b>arg</b> received as " + typeof arg + " content: actions array";
            for (var x in arg) el.innerHTML += "<br><b>arg[" + x + "]</b> content: <span class='data'>" + arg[x] + "</span>";
          }
        }
      </script>
     
      </head>
      <body>
     
      <div>
        <p id="ToolBook">
          This is the content we want ToolBook to modify.
        </p>
      </div>

      </body>
    </html>

    We will name the html document above "remote.html".
    Flag the file for inclusion in the export of the book.
    Drag a field and execute pgGotoURL() for the on load page event of the field.
    Use pgExecuteRemote() to execute the functions in our remote.html document.
Here is my working result:
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Parameters not sent to embedded HTML

Postby John Robin Dove » Mon Jun 27, 2016 8:55 am

Hi Clifton,

Thanks very much for your help. I was able to reproduce your example 100% using the html code you provided. I am indeed using pgExecuteRemote(). (I wouldn't know how to do this any other way.) Unfortunately I still can't get my functions to work and I can see no difference between my app and yours.

Image

The functions are definitely triggered but the parameter is not received. It is always undefined. I think something weird is going on because, as I said, I could get one of the functions to work if I sent the parameter as an actions editor array. I put my global variable total which was set to 1 into myArray[ 0 ]. This worked for a while but now it doesn't! I redfined the argArray parameter as total. This still did not work. Then I typed 1 straight in as the argArray value. This did not work either. I then went back to the version that used to work: myArray[ 0 ] = total => argArray value = myArray[ 0 ] and ... it no longer works!?

UPDATE

I have found a way round this by using functions that do not require a parameter but it's not very satisfactory. Could I send you the files for you to take a look if you have time?
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Parameters not sent to embedded HTML

Postby Clifton » Tue Jun 28, 2016 7:58 pm

Sure I can take a look; just in case there is some bug on our function.

When sending the files, just provide the basic html page and tbk stripped of action code that is not relevant to this investigation.

Send to [email protected]

Thanks!
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Parameters not sent to embedded HTML

Postby John Robin Dove » Thu Jun 30, 2016 1:26 pm

Hi Clifton,

I had some trouble sending the files. I tried [email protected] but my mail was not delivered. I then tried what I think is a typo: [email protected] and also [email protected]. The last address seems to be OK.

John
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Parameters not sent to embedded HTML

Postby Clifton » Thu Jun 30, 2016 9:10 pm

After examining your files, they play fine for me.
I was able to send multiple parameters to your HTML page function and get return confirmation the data was received.

Make sure you are using the latest PowerPac version (v12.916.2) at time of this post.
Also, since your are using ToolBook v9.01, make sure you have the latest Sun Java version on your system (v8 update 91 as of this post).
    Neither of the above may be the reason for the problem. There may be some other action or JavaScript interfering with your real world case.
You may need to try your app from a web server to confirm that some third-party security software is not interfering with running this app from your local hard drive.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Parameters not sent to embedded HTML

Postby John Robin Dove » Fri Jul 01, 2016 6:09 am

Hi Clifton,

Thank you for the info. I am using Powerpac 12.915. Not the latest but almost. I have tested on a web server and have spent the morning trying various computers and older versions of Powerpac but the problem persists. Once again this would suggest that your Toolbook 9.01 is not identical to mine. If you remember we already came to that conclusion (see here http://www.pgsoftwaretools.com/forum/viewtopic.php?f=10&t=2&hilit=transparency&start=10#p576). Yours was bought as 9.01, mine was updated from 9.0. I think it would be a complete waste of time asking Sum Total for anything as they refuse to support older versions of Toolbook. I wonder which is the relevant bit of Toolbook that causes the problem. Maybe tb90actr.sbk or tb90hyp.sbk? Could you re-export the test app to DHTML and send me the folder please? This will allow me to confirm my diagnosis.

In the meantime, I do have a solution! :D I have discovered that if I put the parameters to send into the text of a field and then define the argArray value as text of field ... it works!

Image

Image
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Parameters not sent to embedded HTML

Postby Clifton » Fri Jul 01, 2016 12:47 pm

Link to the last export I made using your testFunction.tbk

You can inspect it for issues that make yours different from mine.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Parameters not sent to embedded HTML

Postby John Robin Dove » Fri Jul 01, 2016 1:02 pm

Yes, it works. I thought it would ...
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron