Forum > Pas2JS

How to call external JS script?

(1/2) > >>

zendrael:
Hello!

I need to call an external JS script, but I don't want to declare all of the external script functions and don't know all of them...

Can I do something like

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---window.ExternalLibName.function()inside my Pascal code?

Thanks in advance, any help is appreciated.

PascalDragon:

--- Quote from: zendrael on October 16, 2023, 02:43:45 pm ---I need to call an external JS script, but I don't want to declare all of the external script functions and don't know all of them...
--- End quote ---

The point of Pascal is to declare first. So you must to declare them.

marcov:
Does pas2js support idispatch ? :-)

PascalDragon:

--- Quote from: marcov on October 17, 2023, 11:55:29 am ---Does pas2js support idispatch ? :-)

--- End quote ---

From what I can see it doesn't.

ps:

--- Quote from: zendrael on October 16, 2023, 02:43:45 pm ---I need to call an external JS script, but I don't want to declare all of the external script functions and don't know all of them...

--- End quote ---

You can declare only function you need. For example:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  TJSSignaturePad = class external name 'SignaturePad' (TJSObject)     constructor new (aTarget : TJSElement; const aOptions : TJSObject);    procedure fromData(Value: JSValue);  end;    

Navigation

[0] Message Index

[#] Next page

Go to full version