I'm developing one firefox extension. In that I need to inject some html elements, when print function is called, into the web page that has been loaded in the current browser tab. And then the page should be taken to the printer along with the injected html elements
I searched for and find onbeforeprint function in mdc
https://developer.mozilla.org/En/DOM/HTMLBodyElement
I'm unaware of using function. I tried using it as an event.
window.addEventListener("onbeforeprint",
function(){alert("Print called");}, false);
But it fails. Please, kindly help me in this regard.
As I understand, this feature was added just recently, and will only be available in Firefox 5 or 6.
Related
I'm looking for a way to open a new browser window from a WebView, from a wp8.1 RT, silverlight or UWP app.
It should happen when the page loads, or after a few seconds, without any user input (I know it's possible if the user clicks on a 'target="_blank"' link)
Does anyone know if any way to do this exists?
I tried with window.open, jquery's .click() or .submit(), but nothing...
Neither the the javascript alert() works, it does work instead redirecting to a uri protocol with location.href and open an app, but unfortunately IE/Edge doesn't have an app protocol to launch it...
Any help would be much appreciated.
Since you put both Windows Phone 8 and Windows 10 in your tags, I can't be sure what to offer you here. SO I will tell you how to do it in 8.
JavaScript in a WebView can call external C# code by using ScriptNotify. You can read more about that in this question: Call Native C# from WinJS that's loaded in a WebView
Also, once you are in C# and you want to launch a browser, the answer is to use the LaunchUriAsync API. Read more about that here: https://msdn.microsoft.com/library/windows/apps/windows.system.launcher.launchuriasync.aspx
Best of luck!
How can I print .docx,doc,xls,csv in rails 4?
I tried window.open and window.print using javascript, but each time when it invokes window.open it downloads the file.
I tried to embed that in an iframe, that also fails.
Displaying a specific type of file isn't something that relies on your application it relies on the browser. In common browsers there is no support to display the file formats you mentioned.
What you can do is implementing some document viewers based on js if they are available for your usage. For example I know there is a plugin viewer.js that provides functionality to convert office and pdf to html. That might help you out... https://developers.box.com/viewer-js-tutorial/
I tried doing this some time back and this is the blog which i refereed. Helped a great deal.
Hope this helps.
Above is just some test code for me to learn how to program with backbone and jqm.
Initially, I think it's always better to start running my code when the document is ready, so I wrap backbone view creation logic in the document ready function: $(function(){ }). But the page is just not showing like a mobile app.
So I tried and tried, and I found when I remove the document ready function part, the page will be displayed correctly, exactly like a mobile app.
What's wrong with document ready function here?
Please help.
I guess that you are applying some Backbone manipulation for elements like #homepage which is trying to manipulate by JQM too. That's why you don't have any problem if you remove the document ready function. You can do this Backbone code inside JQM page event functions.
JQM page events. So the other code works after the pages are rendered by JQM.
Long story short:
We've had errors being logged concerning a JQuery/JQueryUI based system for some time. At it's core we're doing a pretty basic click link -> JQuery AJAX GET -> Open JQueryUI modal pattern.
The error we were getting appeared simple - "Object doesn't support property or method 'dialog'" - leading us to believe there was an error with JQueryUI. After expending a lot of time ruling out browser incompatibilities, bad code on JQuery's end, bad code on our end, angry code gods... we caught a lucky break. A 100% repro on one of the machines in the office.
Turns out the thing was riddled with adware - specifically [an older version of] easyinline - http://www.easyinline.com. When the user clicked any link a cascade of javascript files would be loaded, including reloading JQuery from Google's CDN.
For most links this isn't really a problem - they take you off the page anyway and everything reloads. But for our modals it meant that every modal link would stamp over our JQuery at the point the request was sent, resulting in the response trying to make use of the 'new' $ which would now be missing JQueryUI and any other plugins.
Initially we thought about making another global var ($$ or something) for 'our' JQuery and explicitly using that in our code instead of just $. The issue with that is that we were using a few other 3rd party tools which rely on $ and the adware-loaded $ is a different (older) version. So it's important that we preserve $ correctly.
Any ideas? I'm aware of JQuery's noConflict() method but after a cursory glance don't think it fits the bill.
Ultimately we've decided to re-establish our JQuery integrity when we receive any ajax responses (i.e. just before the open modal code is executed). All our ajax stuff is wrapped in our own handler so this was fairly easy to inject across the board.
Basically;
We have the original JQuery 'saved' - we've got it in-scope thanks to our handler but it could be easily put into a separate global (like $$) just after it is loaded. In our ajax response handler we've got a fairly straightforward check;
if (window.$ !== $$) {
window.$ = window.jquery = window.jQuery = $$;
}
This will reset the global jquery back to what it should be.
well this is just a work around and not a full fledged solution.
you can try multiple things here
1. if you have control over what the adware loads then just put in something like this if(!$) where they try to load the jquery
2. try loading your plugin at the end of the page
3.even if end of the page is not working. Try injecting the link(a script tag using document.write) to the plugins CDN in the Jquery document ready event. this would ensure that the plugins code would be loaded at the end when all the jquery is already loaded (not a preferred thing).
I'm extremely new to jQuery, although not new to javascript in general. I'm trying to use the UI dialog widget. I've downloaded a .min.js file containing the dialog widget and a few others, and already have the core .min.js.
I copied the demo code directly from the UI doc for modal form and pasted it into a plain html file. Clicking the button does not work; nothing happens.
Can anyone tell me if there's something else I need to do to use the demo code? And how do I go about debugging this jQuery stuff in Chrome? (I do have FireBug Lite installed; just haven't quite figured out how to use it for jquery.)
I can post pieces of code if anyone can tell me something specific to look for, but the entire html file, simple as it is, is over 100 lines. Here's a link to my sample.
$( "#create-user" ).button is not a function
it is supposed to be
$( "#create-user" ).click(function(){.....
Judging from the .button() call, you forgot to include a reference to jQuery UI.