pgGotoURl

Posted:
Wed Feb 26, 2020 8:58 am
by John Robin Dove
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
Re: pgGotoURl

Posted:
Wed Feb 26, 2020 10:25 am
by Clifton
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?
Re: pgGotoURl

Posted:
Wed Feb 26, 2020 10:52 am
by John Robin Dove
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.
Re: pgGotoURl

Posted:
Wed Feb 26, 2020 1:03 pm
by John Robin Dove
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.
Re: pgGotoURl

Posted:
Wed Feb 26, 2020 1:09 pm
by Clifton
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.