pgGotoURl

Workarounds and usability notes.

pgGotoURl

Postby John Robin Dove » Wed Feb 26, 2020 8:58 am

Hi Clifton,

I am still trying to reduce the amount of code in a TB file by transferring it to an XML file. This is the last one like this but it is the biggest.

I have a problem. I'm getting this error TypeError: d.contentWindow is null (line number 5) when code loaded by the XML file attempts to use pgGotoURL. The same function, using the same field and URL, used in a TB actions sequence does not produce the error!

As far as I can see it is the TB field, called "pad" which is part of a large group, that is causing the problem. If I use a different field and go to the same URL there is no error message.

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

Re: pgGotoURl

Postby Clifton » Wed Feb 26, 2020 10:25 am

Please post the code you are using in the XML.
The error message suggests that a function is trying to access the content of the field and there is no elemen to interact with. Are you perhaps using pgExecuteRemote() on the field when in fact the URL has not yet fully loaded?
 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: pgGotoURl

Postby John Robin Dove » Wed Feb 26, 2020 10:52 am

Not sure just the code will tell you much. I'll try and make a test app but it's a bit complicated. Here's the code:

<function name="myTrigger" event="trigger" params="">
<![CDATA[
if (sharedActions.myArray[7] == 1)
{
tbfunction_pgGotoURL("pad", "/programs/CKE/pad/pad2.html?config=configFR&color=#40BEFE", "", "", "", "", "", "", true, false, "");
}
else if (sharedActions.myArray[7] == 2)
{
tbfunction_pgGotoURL("pad", "/programs/CKE/pad/pad2.html?config=configEN&color=#40BEFE", "", "", "", "", "", "", true, false, "");
}
else if (sharedActions.myArray[7] == 3)
{
tbfunction_pgGotoURL("pad", "/programs/CKE/pad/pad2.html?config=configIT&color=#40BEFE", "", "", "", "", "", "", true, false, "");
}
else if (sharedActions.myArray[7] == 4)
{
tbfunction_pgGotoURL("pad", "/programs/CKE/pad/pad2.html?config=configES&color=#40BEFE", "", "", "", "", "", "", true, false, "");
}
else if (sharedActions.myArray[7] == 5)
{
tbfunction_pgGotoURL("pad", "/programs/CKE/pad/pad2.html?config=configDE&color=#40BEFE", "", "", "", "", "", "", true, false, "");
}
]]>
</function>

To test this I have replaced the field name "pad" with another field name and then there is no problem. The field named "pad" is part of a complex draggable group.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: pgGotoURl

Postby Clifton » Wed Feb 26, 2020 12:32 pm

I think what may be more important is what happens after you call pgGotoURL() to load your page.
If you are trying to interact with the loaded URL and it has not finished loading, this could possibly trigger an error condition.
I threw together a sample TBK with a group of two objects; one named "pad" and the other named "DragMe".


The group was merged and made draggable using the "DragMe" element as the draggable object.
This is the XML I used and it works as expected:



And my exported page looked like this:
    Image 2.png
    Exported page using above XML configuration.
    Image 2.png (117.04 KiB) Viewed 1438 times

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

Re: pgGotoURl

Postby John Robin Dove » Wed Feb 26, 2020 1:03 pm

Thanks Clifton.
I tried to make a test app but couldn't reproduce the error. I have now realized what is happening. I am calling the trigger which calls pgGotoURL in another part of the same XML presumably before the trigger is ready to respond. In fact I don't really need a trigger at all because I can create a function to do the job in the sharedActions object. Sorry to waste your time.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: pgGotoURl

Postby Clifton » Wed Feb 26, 2020 1:09 pm

Good to keep in mind that XML files are processed from top to bottom. So the order of your tags can be important depending on the purpose of the XML configuration.
Glad to you figured it out.
 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron