I use JavaFx 8 WebEngine (custom browser)
In my html page i have print button
document.querySelector('.check').onload = function() {
setTimeout(function() {
window.print();
}, 500)
}
I want by clicking on the button print - catch this with your WebEngine
and send the document for printing.
The question is how to do this?
there is no such event in the documentation.
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/web/WebEngine.html
window.alert() onAlert
window.confirm() confirmHandler
window.open() createPopupHandler
window.open() and
window.close() onVisibilityChanged
window.prompt() promptHandler
Setting window.status onStatusChanged
Related
I have a button within my main ApplicationWindow (root) that dynamically loads and opens a second, different ApplicationWindow that is declared in a separate .qml file.
Button {
id: btnLogger
text: "Logger"
onClicked: {
var component = Qt.createComponent("logger.qml")
var window = component.createObject(logRoot)
window.show()
}
}
This works fine for opening a window when clicking the button. Subsequent clicks create further new windows.
My intent is that subsequent clicks should instead focus the preexisting window. If the new window is later closed, then clicking the button should revert back to opening the window.
i.e. if a window doesn't currently exist or exists but has been closed, create it and open it; else, focus it.
How would this be done from within qml? Alternatively, I am currently loading the application from a QQmlApplicationEngine in my C++, how could I use that to achieve this functionality?
The example code for my comment above:
Button {
id: btnLogger
text: "Logger"
property var wnd: undefined
onClicked: {
if(wnd == undefined)
{
var component = Qt.createComponent("logger.qml")
wnd = component.createObject(logRoot);
wnd.closing.connect(function() { btnLogger.wnd = undefined;});
wnd.show();
}
else
{
wnd.requestActivate();
}
}
}
In asp.net, I want to click on a button to open a popup windows. after the popup windows, I want to cause a full postback to the parent window.
How can I do this?
On your popup write the below script:
window.opener.PostBack();
// Where PostBack is the custom method of opener/parent window.
Either you can do it in OnUnload() event of your popup or from any other method followed by window.close();.
You can implement the PostBack() method like this in opener:
function PostBack() {
var btn = document.getElementById('<%=SomeButton.ClientID %>');
if (btn) btn.click();
// or
// __doPostBack('SomeButtonId','Arguments');
}
How to disable Save As dialog while pressing Ctrl+S
Description: I am developing one web application.Here When i am going to form submitting using "Ctrl+S",In Firefox before submitting "save As dialog" will open.How to disable save As dialog in Firefox.
You can accomplish this by handling the window's onkeypress event to check whether the CTRL key and S are depressed, and if so, canceling the event from by calling preventDefault() on the event object:
window.onkeypress = function(event) {
if (event.charCode === 115 && event.ctrlKey) {
event.preventDefault();
// your code here....
alert("'Save As' dialog suppressed!");
}
};
Note that the keypress event may behave differently in different browsers. This did work in FireFox, however.
I have a webform and i want to detect if F5 button was pressed or if the page was refreshed. I know about postback but it is not what i'm looking for. I have a gridview that loads in a modal popup when a button is clicked and a parameter's value is set for the gridview. When refresh is hit and if the modal popup button was previously clicked the modal popup is visible right after refresh. I want to detect if the page is refreshed to prevent this. any ideas? I thought to try Override but I'm not exactly sure how to use it. I tried Control.ModifierKeys but I don't have access to ModifierKeys.
Pressing F5 or physically clicking the browser refresh behaves similarly to navigating away from the page. This is captured in the event window.onunload. Try the snippet example below:
window.onbeforeunload = function (evt) {
var message = 'Are you sure you want to leave?';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
}
return message;
}
This will capture the refresh and allow you to do something or prompt the user.
Reemember that hotkeys are processed in the client side in the browser. The easiest way to implement this is through javascript.
Look at the following link:
http://snippets.dzone.com/posts/show/3552
I currently open a pop up window from my parent page using using a JavaScript .showModalDialog function. The pop up window contains some ASP.NET validation controls which do not display when the user clicks the ASP.NET button to submit the form. If there is an error on the page, the validation message(s) do not display, the record is not updated on the server side and the pop window closes.
(The asp.net validation controls do not stop the pop up window from doing a server postback)
Has anyone expereinced this behavior before and is there any way to prevent it?
Here is my showModalDialong call source code:
function OpenChildWindow(id)
{
var sFeatures = sFeatures="dialogHeight: 525px;";
sFeatures += "dialogWidth: 900px;";
sFeatures += "scroll: yes;";
sFeatures += "status: no;";
sFeatures += "resizeable: no;";
var url = "MyPopUp.aspx?ID=" + id;
var childName = "ChildForm";
entryWindow = window.showModalDialog(url, childName, sFeatures);
if (entryWindow == true)
{
window.document.getElementById("<%= btnUpdateParent.ClientID %>").click();
}
}
Note: When the pop up modal is closed, a ASP.NET button is "clicked" to update an ASP.NET UpdatePanel on the parent to show the changes to the record modified in the pop up window.
I think this may be due to a notorious problem with modal dialogs and postbacks. You can try adding the following in the head tag of the page which you open with window.showModalDialog
<base target="_self" />