final ActiveXComponent activeXComponent = new ActiveXComponent("CLSID:0CA54D3F-CEAE-48AF-9A2B-31909CB9515D");
webClient.getOptions().setActiveXNative(true);
The following is the content of the DLL function
How do I call it?
HtmlUnit simulates real browsers.
So you usually have a web page which loads this ActiveX component and calls its properties and methods.
E.g.:
<script>
function createFile() {
var object = new ActiveXObject("CLSID:0CA54D3F-CEAE-48AF-9A2B-31909CB9515D");
}
</script>
Related
I have a vue.js 3 application that needs to dynamically create components and access them.
The proper way to dynamically create them and injected them in the DOM seems to be th wrap them in an app using createApp, and this part works, when I call test() a new copy of the components appears at the bottom of the DOM.
Now I need to be able to get a reference to that component son I can call public (exposed) methods on it.
In my (actual) code below, what would allow me to get a reference to my component ?
import { createApp, h } from "vue";
import ConfirmModal from '#/views/components/ui/confirm-modal.vue';
function test()
{
let componentApp = createApp({
setup() {
return () => h(ConfirmModal, { title: "Fuck yeah!", type: "primary" });
}
});
const wrapper = document.createElement('div');
wrapper.setAttribute('id', 'confirm-modal-0');
componentApp.mount(wrapper);
document.body.appendChild(wrapper);
let _confirmModal: ConfirmModal = ???????????????????
_confirmModal.show();
}
EDIT : Here's my use-case: I have a helper function in a service which is used to confirm actions (like deletes) using a Modal dialog. This helper/service is pure TS, not a Vue component, but needs to instanciate the modal (which is a vue component), have it injected in the DOM and have its public methods callable (by my helper/service).
Right now, the only thing that works is to have a sungle copy of the modal component in my root layout and have to root layout foward the ref to my service, which can then use the component. But this isn't great because I need multiple instances of the dialog, and isn't good SOC to have to root layout handle a modal dialog.
i want to dynamically create DIV Containers via JSInterop in Blazor Webassembly. My approach was to create a CreateElement method in C# which calls createElement in javascript and returns a ElementReference as a Result. But when i run the Following code, i just get an empty object.
C# code:
public object CreateElement(ElementReference elementReference)
{
return JsRuntime.Invoke<object>("createElement",
elementReference,
DotNetObjectReference.Create(this));
}
Javascript code:
createElement(element, objectReference) {
const newDiv = document.createElement("div");
return element.appendChild(newDiv);
}
You don't need JS for that. Blazor was made so you don't have to manipulate the DOM. Create components. Manipulating the DOM this way defeats the purpose for which Blazor was made. You may want to start with some basics at https://learn.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-3.1
As #Porkopek mentioned, there's not really a good reason to do this as it more or less defeats the purpose of using Blazor to dynamically render markup.
If you absolutely have to use createElement, you should bind your JS interop code to the window object to invoke:
window.createDivElement = createElement(element, objectReference) {
const newDiv = document.createElement("div");
return element.appendChild(newDiv);
}
Side note, DotNetObjectReference.Create(this) is for calling back into C# component methods via the [JSInvokable] attribute and probably not needed here.
Help me solve with the problem please.
I am using jquery and jquery-ui to implement drag & drop in QASAR CLI.
But I ran into the fact that I cannot access the vue instance from jquery function events, since "this" no longer belongs to Vue, but refers to the selector element. Tell me how I can refer directly to the vue instance as it could be done in cdn version. There you could just give the name app = new Vue ... And then use it as app.data.variable
I believe this is more javascript question, than quasar/vue/jquery. You can easily set value of this by a bind function
let someFunction = function () {
console.log(this);
}
someFunction();
const obj = { 'test': 123 };
someFunction = someFunction.bind(obj);
someFunction();
Same thing applies to jquery function handlers. I guess you could pass your instance instead of obj
$(window).ready(function () {
console.log(this);
}.bind(obj));
I have a metro application in which I want to call a javascript function from another .js file? can anyone help me.
Thank you.
All scripts in javascript are merged into a "script context". This means that if you have:
File1.js:
function a() { b(); }
File2.js:
function b() { alert("hi"); }
then as long as file2.js is included before b is called, everything will be fine.
This means in your HTML should have the <script> tags included, and you'll be good.
If you are using WinJS, a better example might be:
File1.js:
WinJS.Namespace.define("MyNamespace", {
firstFunction: function() { MyNamespace.secondFunction(); }
});
File2.js
WinJS.Namespace.define("MyNamespace", {
secondFunction: function() { alert("hi"); }
});
default.html:
<script src="/file1.js"></script>
<script src="/file2.js"></script>
However JavaScript doesn't have a built in dynamic loading of "References". You have to build or use your own.
There are many ways to skin this cat, so I would recommend you look a them and decide which meets your needs.
Require JS
Built in Page controls/fragment loading in WinJS. If you define a page in WinJS, when the html file for that page is loaded, any scripts declared in the html will be brought in automatically. Same is true of raw fragment loading.
You can just the file that contains the definition of the function needs to be referenced before the file which calls the function just like you would do if it was a browser not a Windows 8 app.
In fact not even that much is necessary. If you are calling the function after window.load or document.load then that means that all of your referenced javascript files have loaded already so the reference sequence doesn't even matter.
Just like the question title says:
I've got a standard jquery ui tab set. One tab is to another php file, from which i would like to be able to call a function with an argument on the parent page. Can't figure out how to do it.
Code in external page loaded into the tab:
<script language="javascript">
function doSomething(){
parent.dummyfunction("Hello world!");
}
</script>
<input type='button' value='use recipe' onClick='javascript:doSomething()'>
and on the parent, where the tabs are defined, I have:
<script language="javascript">
function dummyfunction(whatever){
alert(whatever);
}
</script>
Thank so much for looking
OK I've figured it out. The jquery ui tabs code loads the external file into the target div as flat html. So instead of needing to call a middle-man function (like the doSomething function in the above example), we just call dummyfunction directly, even though the function is not defined on the external page.