thecrgrt Posted May 19, 2011 Share Posted May 19, 2011 How do I exchange data between my delphi code and Java script? At least with WebForm.JSCode and Form Script property. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 19, 2011 Administrators Share Posted May 19, 2011 How do I exchange data between my delphi code and Java script? At least with WebForm.JSCode and Form Script property. Can you give a specific example? Quote Link to comment Share on other sites More sharing options...
thecrgrt Posted May 19, 2011 Author Share Posted May 19, 2011 Can you give a specific example? Get some values from or set some values to JS controls, create an event for some JS controls in JavaScript using Delphi code. By the way, I found the interest property, JSName that I can create dynamic JavaScript to receive an information from Delphi code, but where is JSCode method of WebForm? why it disappeared from 0.85.0? Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 19, 2011 Administrators Share Posted May 19, 2011 Get some values from or set some values to JS controls, create an event for some JS controls in JavaScript using Delphi code. By the way, I found the interest property, JSName that I can create dynamic JavaScript to receive an information from Delphi code, but where is JSCode method of WebForm? why it disappeared from 0.85.0? JSCode is a protected method: Use a hack to access it: type TUniControlHack = class(TUniControl); procedure TMainForm.UniFormCreate(Sender: TObject); begin if WebMode then TUniControlHack(WebForm).JSCode('alert("blalalala");'); end; Quote Link to comment Share on other sites More sharing options...
thecrgrt Posted May 19, 2011 Author Share Posted May 19, 2011 JSCode is a protected method: Use a hack to access it: type TUniControlHack = class(TUniControl); procedure TMainForm.UniFormCreate(Sender: TObject); begin if WebMode then TUniControlHack(WebForm).JSCode('alert("blalalala");'); end; Thank you, I'll try its. Quote Link to comment Share on other sites More sharing options...
acesar Posted May 19, 2011 Share Posted May 19, 2011 Hi, Farshad... How can I execute this code? if WebMode then TUniControlHack(WebForm).JSCode( '<link rel="stylesheet" href="dhtmlwindow.css" type="text/css" />'+ '<script type="text/javascript" src="dhtmlwindow.js">'+ 'dhtmlmodal.open("EmailBox", "iframe", "modalfiles/newsletter.htm", "Newsletter Signup page", "width=350px,height=200px,center=1,resize=0,scrolling=1");'); Method dhtmlmodal is inside a .js called "dhtmlwindow.js". I put this file in same application path, but script doesn't works. Can you help me? Thanks Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 19, 2011 Administrators Share Posted May 19, 2011 Hi, Farshad... How can I execute this code? if WebMode then TUniControlHack(WebForm).JSCode( ''+ '<script type="text/javascript" src="dhtmlwindow.js">'+ 'dhtmlmodal.open("EmailBox", "iframe", "modalfiles/newsletter.htm", "Newsletter Signup page", "width=350px,height=200px,center=1,resize=0,scrolling=1");'); Method dhtmlmodal is inside a .js called "dhtmlwindow.js". I put this file in same application path, but script doesn't works. Can you help me? Thanks You can't put html inside JSCode(). Put "dhtmlwindow.js" inside ServerModule.CustomFiles Then put your html/js code inside a uniHTMLFrame Quote Link to comment Share on other sites More sharing options...
acesar Posted May 19, 2011 Share Posted May 19, 2011 Thank you!!! I got what I wanted! Quote Link to comment Share on other sites More sharing options...
LordDelphi Posted May 20, 2011 Share Posted May 20, 2011 a very interesting code. There is something like this to do the opposite? Delphi receive a value from javascript. Quote Link to comment Share on other sites More sharing options...
thecrgrt Posted May 20, 2011 Author Share Posted May 20, 2011 a very interesting code. There is something like this to do the opposite? Delphi receive a value from javascript. Whether JSCall and JSCallCatch methods can do this, IMO. But I don't know how to use them, maybe we wait for Farshad answer. Quote Link to comment Share on other sites More sharing options...
richard_wu Posted May 20, 2011 Share Posted May 20, 2011 Hi, Farshad can you provide a demo to learn Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 20, 2011 Administrators Share Posted May 20, 2011 Hi all, We will try to support client side scripting as much as we can,but we shouldn't forget that there are almost infinite possibilities when you combine JS/HTML/CSS and similar technologies. In order to exchange values between Delphi and JS we need to construct the proper infrastructure which will handle all these tasks in a reliable and automatic way. Currently you can achieve this, but for this you need to use some dirty hacks which may work only for a particular problem. After version 0.90.0 or maybe earlier we will start to focus on client side scripting and event handling. Until then I will try to answer simple cases regarding scripting, but for more complex cases, especially those which need implementing a two way communication between server and client, I may not be able to solve your issue. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.