Calling WPF Application Function from JavaScript Button - javascript

I have a xbap application and i would like a javascript button to call a function from this application.
I've read something on Internet and it seems i have to use either a webcontrol (is that correct?) or an object control whom to pass an id or something. How should i do that exactly? A small Vb.Net example would be useful.
Let's assume i have this class:
Class Page1
Public Sub Callback()
MsgBox("Something")
End Sub
End Class
And i have a html file with an iframe that looks like this:
<html>
</head>
<script>
function something() {
var ctrl = document.getElementById("testControl");
ctrl.Callback();
}
</script>
</head>
<body>
<object id="testControl" name="testControl" classid="clsid: ..." width="0" height="0"></object>
<input type="button" value="Change Size" onclick="something()" />
<br/>
<script>
document.write('<iframe id="frame1" name="frame1" width="200" height="197" src="http:// .... .xbap?id=' + 1 + '" frameborder="1" border="1" style="border: 1px solid #000000;" />');
</script>
</body>
</html>
How should i configure my vb.net class and html file so that it works? thank you.

This question seems to be unanswered, and is most likely bit duplicate with other questions out there.
But any how, I have created a blog post where there is a javascript button that calls function from xbap. This solution works with latest browsers out there.
Check it out at:
http://hotzblog.com/xbap-and-javascript-with-ie9-or-newer-solution-for-missingmethodexception-problems/

Related

Accessing PDFium plugin methods with JS in Chrome 2019

I would like to access the PDFium API, that is the pdf viewer in Chrome.
It is not clear what can I do.
Some old questions give some hints.
does pdfium expose its api to javascript? i want to get the number of current page, but how to do this?
Call pdfium (chrome native pdf viewer) from javascript
I created a HTML file but I see that the methods of the plugin are not working.
<html>
<body >
<embed id='embedId' width='100%' height='100%' name='plugin' src='C:\path\file.pdf' type='application/pdf' />
<input type="button" value="Click me" onclick="embedEl=getElementById('embedId'); embedEl.selectAll();">
</body>
</html>
I would like to know whether the API is available at present time in Chrome (so to be able to build something upon it) or not.
Hi you can find some API methods here:
https://cs.chromium.org/chromium/src/chrome/browser/resources/pdf/pdf_scripting_api.js
Here is a basic example, it gives out an alert when the PDF loads.
<html>
<body style="overflow:hidden;">
<embed width="100%" height="100%" id="plugin" src="test.pdf" />
<script type="text/javascript" src="pdf_scripting_api.js" />
var plugin = document.getElementById("plugin");
var scriptingAPI = new PDFScriptingAPI(window, plugin);
scriptingAPI.setLoadCallback(function(success)
{
alert(success);
});
</script>
</body>

Know when a a webpage inside IFrame (situated in an HTA) has completed loading

I have an HTA, which in turn has an Iframe. We are loading an intranet website. A button in the HTA, when clicked, will automate some task. The first step is to login, wait for the next page to load, then perform next option. The main concern here is to know that the next page has been loaded completely, so that we can initiate the code related to page ?
Can some one shed light on how to achieve this. Just to repeat, IFrame is inside HTA.
Below is my code :
<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="HTA"
SYSMENU="YES"
NAVIGABLE="YES"
>
<meta http-equiv="x-ua-compatible" content="ie=11">
<title>HTA</title>
<script type="text/javascript">
window.resizeTo(900,700);
</script>
<script type="text/javascript" >
function Start() {
var iframePage = document.getElementById("iframeid").contentDocument;
var userId = iframePage.getElementById("userid");
var passwd = iframePage.getElementById("pwd");
var form = iframePage.getElementById("login");
userId.value='aa';
passwd.value='bb';
form.submit();
var iframePages = document.getElementById("iframeid").contentDocument;
var targetContent = iframePages.getElementById ("ptifrmtgtframe").contentDocument;
var runcntl = targetContent.getElementById("PRCSRUNCNTL_RUN_CNTL_ID");
runcntl.value='test';
}
function Show() {
document.getElementById("iframe").style.display = "block";
}
</script>
</head>
<body>
<form class="form" name="form">
<input class="links" type="button" value="Show PIA" onclick="Show();" />
<input class="links" type="button" value="Login" onclick="Start();" />
</form>
<br>
<div class="iframe" id="iframe" style="display:none">
<iframe application="no" src="my URL" width="600" height="600" id="iframeid">
</div>
</body>
</html>
I want that:
var runcntl = targetContent.getElementById("PRCSRUNCNTL_RUN_CNTL_ID");
runcntl.value='test';
Should run, only after the page in the IFrame has loaded properly and completely, since only then the relevant feilds will be loaded. Or else, this will give error.
PS This is a PeopleSoft site.
Here is a simple example of calling code when the iframe has loaded. Check out the onload attribute of the iframe tag. Maybe you can integrate this into your HTA?
<head>
<script>
function frameLoaded() {
alert('frame loaded!');
};
</script>
</head>
<body>
<iframe id="frame" src="https://en.wikipedia.org/wiki/HTML_element#Frames" onload="frameLoaded(this)" />
</body>
If you have access to the page, use javascript inter-window communication to trigger the JS you need. The child iframe can tell the parent when to run java script.
From a pure PeopleSoft perspective you can use related action framework component events to do what you like, too, without customization.
I think you can check the code for related content as reference. Such as OpenRCService and onRCService. In PT_COMMON, the showModalDialog method also related to the RC function which have the logic to detect a iframe is loaded.

How do I add text to a paragraph tag via JQuery?

I'm trying to write my first chrome extension to test my acquired knowledge from codecademy (HTML/CSS, JQUERY and Javascript). First of all I'm trying to append text to a paragraph tag via the onclick of a button.
heres my code:
<!doctype html>
<html>
<head>
<title>Facebook event graph</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script src="popup.js"> </script>
</head>
<body>
<form id="inputUrl">
Enter a URL: <input type="text" name="url" id="url">
<button type="button" onclick="getFacebookData()"> Get Data </button>
</form>
<canvas id="graph" width="300" height="100">
</canvas>
<p id="text" width="300" height="100">1</p>
</body>
</html>
and my popup.js:
$(document).ready(function(){
//Variables
function getFacebookData() {
$('p').append('Test');
};
});
it's probably something very basic that I'm doing wrong, but a push in the right direction would be really appreciated :)
You are not allowed to use inline scripting like onclick="getFacebookData()"
You have to remove the handler from html:
<button type="button" id="my-button"> Get Data </button>
And you have to move the handler into popup.js:
$(document).ready(function(){
$('#my-button').click(getFacebookData);
});
You are also, by default, not allowed to load jQuery from an external CDN - and certainly not http one, again for Content Security Policy reasons. And you shouldn't! Put jQuery in your extension's folder and load it locally.
Matter of taste, but I would place getFacebookData() definition outside $(document).ready, so it's available in the global scope. Also, the semicolon after it is not needed.
Last, but not least: for future debugging, inspect the console of the corresponding page of your extension. For things like background/options page you should be able to access them from Developer Mode extensions list. For a popup, you should right-click the button of your extension and select "Inspect Popup".

Calling JavaScript function in WebView

I know this question has been asked many times and I have checked all the solutions and researched everything. However, this is simply not working for me.
I don't know what I am doing wrong. Can someone please help me out?
I am loading a local html file in my WebView and then calling the JavaScript function:
wv.loadUrl("file:///android_asset/sample.html");
wv.getSettings().setJavaScriptEnabled(true);
JavascriptInterface javasriptInterface = new JavascriptInterface(MyActivity.this);
wv.addJavascriptInterface(javasriptInterface, "MyInterface");
wv.loadUrl("javascript:loadpath()");
The HTML file is:
<html>
<head>
</head>
<body>
<script type="text/javascript">
function callDoSomething() {
// Do something
}
function loadpath() {
// Is not called no matter whatever operation I do here. Just printing a string, setting variable, android callback anything.
document.write("Hi");
document.getElementById('img').src = "path.png";
}
</script>
<form name="myForm" action="FORM">
<img src="" alt="Autofill" /><br>
<input type="button" value="Submit" onClick="callDoSomething()" />
</form>
</body>
</html>
loadUrl() is asynchronous. You are calling your second loadUrl() way too soon. You need to wait until your page is loaded, perhaps by using a WebViewClient and watching for onPageFinished().

Calling an Applet method from Javascript in a JSP Page

I have been trying to embed an applet within a JSP page to call some needed methods. The applet is initialized correctly but the method call does not work.
With HTML, a similar example was working fine, but with JSP the method call does not seem to work.
Here is my JS function:
function myFunc() {
alert('begin');
(document.applets['MyApplet'].getName1());
alert("done");
return true;
}
Here is the JSP part:
<body >
<script src="http://www.java.com/js/deployJava.js"></script>
<button onclick="return myFunc();" >button</button>
<jsp:plugin align="middle" height="500" width="500" type="applet" code="MyClass.class"
name="MyApplet" codebase="."/>
</body>
I have tried using the applet tag and it is not working either.
If someone has any experience with this, it would be very helpful.
Thank you.

Categories

Resources