Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delphi code not executing when called from Javascript on Chrome, Edge 15.2.36
#1
Hello,

We have code that after clicking a link with parameters, the user is directed to javascript code that redirects them to their already open instance of the Delphi project, updated with parameters from the link they clicked on. However, after stepping into the code that calls the Delphi function and inspecting the res variable it is null, and I am not able to trace it into Delphi. Below is a sample of the Javascript code.


Code:
function pageInit() {
var res;
   getURLParameters();
   if ( (acctnbr == "") || (reqid == "") ) {
      alert('No account number or request id was passed in from dummy software. Account=' + acctnbr + ' Request ID=' + reqid);
   } else {
      try {
         win1 = window.open("", "ApplicationName", "");
         res = win1.functionwithinDelphi(acctnbr, reqid);
         if (res == true) {
            win1.focus(); }
      } catch (ex) {
         // If error is that object doesn't support property or method,
         // then user is probably not logged into application.
         if ( (ex.message.indexOf("annot find submit co") > -1) ||  (ex.message.indexOf("is null or not an object") > -1) ) {
            alert('Application not on main page.  Please correct and try again.');
         } else {
            alert('An error occurred: ' + ex.message + ' Please restart application and then try again.');
         }
      }
   }
on the 'res = win1.functionwithinDelphi(acctnbr, reqid);' line is where the Delphi code is to executed, however, it does not work on Chrome or Edge. Is there a workaround for this? 
Reply
#2
You probably have a javascript bug. Try using something like jitterbug to find the javascript error.
Reply
#3
Not sure if I follow...

I don't think this would ever work the way you intend it...

Anyway, it would be easier if you can submit a simple test case showing the issue.
Reply
#4
This looks like a browser security/compatibility issue rather than a Delphi problem. Modern Chrome and Edge no longer support calling arbitrary functions in another window the way older browsers did. You may need to replace this JavaScript-to-Delphi call with a supported communication mechanism, such as postMessage or a URL/API-based approach.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)