I would like to know about Javascript. Is Javascript available only for web browsers? Because I used some Javascript code for Firefox Plugin development and Thunderbird.
Help me to find out more about this: where can I use JavaScript other than web browsers, and how?
There's node.js which includes a full webserver and runs on Google's V8
No! Have a look at Google's V8
Google Javascript. Click first link (Wikipedia). Click "uses outside webpages".
http://en.wikipedia.org/wiki/JavaScript#Uses_outside_web_pages
There are a number of server-side (or otherwise non-browser) implementations of Javascript, including Node.js, which currently has a lot of momentum behind it, as well as the now-defunct Jaxer, which provided a server-side DOM implementation based on Mozilla Gecko. There are also efforts to bring DOM type functionality to Node.js, primarily from Yahoo.
With Rhino, you can embed Javascript in Java applications.
No, there are definitely other implementations. For instance, JScript.Net is included with the .NET framework.
MS-Windows can execute .js files (from the command prompt).
Since you do not have the browser context, you cannot use any calls to the browser (alert, for example, does not work).
Look for "Windows Scripting Host".
WSH supports scripts written in
Microsoft Visual Basic Scripting
Edition (VBScript) or JavaScript.
There are several implementations of stand-alone Javascript
JSLibs (http://code.google.com/p/jslibs/) is general purpose
jsdb (http://www.jsdb.org/) is more database oriented
Many text editors (including the one I use, ActiveState's Komodo Edit) expose their APIs and let you write macros in Javascript.
Using Adobe AIR you can write almost platform-independent Desktop Applications using JavaScript
PDF files can also contain JavaScript code. See first entry in google on this subject and also Adobe JavaScript virus.
Javascript can be easily embedded in applications written in other programming languages.
For Java there is as already mentioned Rhino, for C++ you can use for example Flusspferd. Here are some tutorials/examples.
Qt has the QtScript module. From Qt 4.7 it uses JavaScriptCore (the Webkit JavaScript engine).
In short, No.
Actually, Javascript and other Web technologies are used these days to create native mobile and desktop applications. (see Titanium Appcelerator and PhoneGap)
If you are familiar with the KDE project you can craft Plasma widgets using JavaScript, see Creating plasmoids with JavaScript
In Qt framework there is a QtScript module for JavaScript (ECMAScript) application scripting to provide much of the application’s functionality.
Also the new technology that is soon to be released in Qt 4.7 is Qt Quick, aka the Qt UI Creation Kit, which allows application developers to declaratively define their user interfaces in QML, for more information go here and an example here
QML is an extension to JavaScript,
that provides a mechanism to
declaratively build an object tree of
QML elements. QML improves the
integration between JavaScript and
Qt's existing QObject based type
system, adds support for automatic
property bindings and provides network
transparency at the language level.
And let's not forget Javascript is used as an embedded scripting language in various applications OpenOffice.org, Google Desktop Widgets, and many others, see Wikipedia's article here
On the server-side Javascript enables back-end access to databases, file systems, etc (see Node.js, Google V8, SpiderMonkey and others here)
Some document databases, such as CouchDB and MongoDB, use JavaScript to interact with the database.
Related
I built a PHP / JavaScript website for a customer. Then they asked me to replicate it except as a standalone Mac application. I did this with an app that combined an embedded web server, PHP, and 'WebView' - a Cocoa-ish version of the WebKit web browser that I can embed in a standard app window. This all worked great - I got to reuse 10,000+ lines of PHP/JS code, which saved months off of re-implementing it all again in 'native' code.
Now they want a Windows equivalent. I'm reasonably confident I can get PHP and the web server to work. And I know embedding basic IE functionality is pretty easy.
However...in my Mac setup, WebView (via the windowScriptObject stuff) gave me the ability to call JavaScript methods from C++. For instance, I might call a JavaScript method from C++ to update the screen. Likewise I could set things up so that a JavaScript call in the browser could trigger a C++ method - I used this, for instance, to let a user click 'BROWSE' and pick a file path using a real, standard file browser.
So my question is, is there a Windows-based embedded browser setup that would let me interact with JavaScript in this same way?
(the JavaScript <--> WebKit interface is described in much better detail here: http://lipidity.com/apple/javascript-cocoa-webkit/)
Maybe try using something like Appcelerator Titanium so you'll be ready when your client says they want it to work on Linux, or iPhone, or Android.
Quoting Wikipedia: "Appcelerator Titanium is a platform
for developing mobile and desktop
applications using web technologies.
[...] Support for standards-based web
technologies: HTML, CSS and Javascript
on all platforms along with PHP,
Python and Ruby for desktop platforms.
Integrated support for popular
JavaScript and AJAX Frameworks
including jQuery, YUI, MooTools,
Scriptaculous and others."
Sounds like a perfect tool for the job.
When you embed the Web Browser Control (IE), your application code can simply call execScript (http://msdn.microsoft.com/en-us/library/ms536420(v=vs.85).aspx) on the window object. You can have your script call out to the application by using the window.external object from the script, and by using the ObjectForScripting (or C++ equivalent) from the application.
maybe Qt will be good for your case, also you have QtScript and can inject javascript with evaluateJavaScript
I found a great example on the web for invoking JS in my embedded browser from C...basically using COM-ish methods that let you get a DISPID from a script object, and then using the Invoke() method with that. This works great.
But it turns out I need to also call C++ funcs from my JS code. It appears this is possible, and after hours of messing around I think I almost had it - it's like the above in reverse - you create a COM object, then hook it to the browser's script object - but in the end I could not close the deal - I kept getting "library not registered" errors. Honestly I don't know COM well enough to do this right.
So then I, for the heck of it, tried building my first C# app. In about 20 minutes I had an app running with a browser where I could both invoke JS inside of it and have the browser invoke C# methods. Geesh. I'm a believer in .NET after this experience, and a confirmed non-believer in 90's Microsoft technology.
In the interest of completeness, I'd like to mention my Windows port of WebKit, which includes the various cross-layer features of WebKit on the Mac.
I posted some example code showing how to embed WebKit in a native WinAPI application, complete with JavaScript->C++ and C++->JavaScript examples.
The example is a tiny test case for a much larger application using embedded WebViews for major UI components. I can confirm that what you are doing is not only possible, but a great way to build an application.
Are there any libraries or frameworks that provide the functionality of a browser, but do not need to actually render physically onto the screen?
I want to automate navigation on web pages (Mechanize does this, for example), but I want the full browser experience, including Javascript. Thus, I'd like to have a virtual browser of some sort, that I can use to "click on links" programmatically, have DOM elements and JS scripts render within it, and manipulate these elements.
Solution preferably in Python, but I can manage others.
PhantomJS and PyPhantomJS are what I use for tasks like these.
What it is, is a headless WebKit based browser which is fully controllable via JavaScript. There's a C++ implementation (PhantomJS) and a Python one (PyPhantomJS). I prefer the Python one though, because it has a plugin system which allows you to add functionality to the core without actually modifying any code, unlike the C++ one. :)
There is an absolute ton of free software technology now available: take your pick at http://wiki.python.org/moin/WebBrowserProgramming but if you have specific questions join pyjamas-dev on google groups and i'll be happy to give further details, there. brief answer: you can run pywebkitgtk "headless", or you can use xulrunner (via python-hulahop) again using pygtk without actually doing "browserwidget.show()", and there's also pykhtml. also you could use python COM to connect to MSHTML.DLL.
these are all "cheat" methods: using python bindings to a graphical web browser engine without actually firing up the graphical bit. if you really wanted to put some serious hard-core programming in, you could create a "port" of webkit which was not connected to a GUI toolkit: as an experienced webkit programmer i'd put it as around... 2 weeks of full-time effort to make such a "headless" version of webkit.
l.
Looks like http://watin.sourceforge.net/ might be a good way to go.
If you don't have to go pure Python, you could do IronPython since it's a C# project.
take a look at this little doosy on ajaxian
http://ajaxian.com/archives/server-side-rendering-with-yui-on-node-js
It also talks about Aptana Jaxer which I think runs on a headless firefox so is basically the Mozilla browser engine in all it's glory.
There is Kapow. Its pure Java and costs money:
http://kapowtech.com/
And there is Lixto: Its Eclipse based and uses Mozilla Gecko as rendering engine (unless they already changed it to WebKit, as they said they'll do years ago). Its very nice and also costs money:
http://www.lixto.com/?page_id=50
They are both graphical tools where you define the site navigation and what should be extracted by point and click. But you can also write xpath and regular expressions and even JavaScript that runs in the sites context.
I used them both in the lectures web data extraction and applied web data extraction at the technical university Vienna (Lixto is written by the Professor who held the lecture).
HTMLUnit in Java is very good. I think it's only the Java implementations of headless browsers that manage to provide Javascript support.
MaxQ, I read about here, sounds like it might be interesting: "written in Java, generates Jython scripts"
Try HtmlUnit !!!
Javascript is widely used to create apps in the web. How about desktop, etc? Gnome Shell is made of it. I'm just curious if there's a way or something which allows devs to access Gnome/Clutter graphics libraries?
The three best options that I know of are Rhino (using Swing, or other Java graphics frameworks), Seed, and Gjs.
Seed and Gjs are both Gnome projects that bind the GTK+ and Gnome libraries to JavaScript. Seed uses the JavaScriptCore runtime from WebKit and Gjs uses Mozilla's Spidermonkey engine. Gnome Shell is using Gjs.
Another option that, as far as I know, is still pretty immature is Gom. Instead of just a JavaScript binding for GTK+, it has an HTML-like DOM interface.
There are various ways to do this. Besides Rhino, V8/node.js is one of them.
Yes using Rhino although it looks like a convolated path...
Check this recent post by Alan Knowles.
I dont know much about the Gnome/Clutter graphics access, But several SSJS (Server-side_JavaScript) available that can work on Linux environments.
i am new in iphone application and i want to integrate the javascript so would you please give some information about how to implement javascript?
I don't know what exactly you mean by
i want to integrate the javascript
You have full JS support inside UIWebView. You can inject your own JS code and communicate with the existing JS code.
According to the policy set by Apple on applications for the iPhone, you can not use any interpreted language. Thus, Javascript is unfortunately out of the question.
This is stated in the iPhone SDK agreement.
3.3.2 — An Application may not itself install or launch other executable
code by any means, including without
limitation through the use of a
plug-in architecture, calling other
frameworks, other APIs or otherwise.
No interpreted code may be downloaded
or used in an Application except for
code that is interpreted and run by
Apple’s Documented APIs and built-in
interpreter(s).
Continuing with what Michael Kessler said you can also use javascript embedded in a UIWebView to access native iPhone functionality via libraries such as phoneGap making your javascript more powerful than the normal safari variety.
http://phonegap.com/download
Includes a iPhone project that you can use as a basis for your javascript application.
I'm attempting to automate login into my small community bank, navigating through several links, and then downloading the .OFX.
I can't seem to find a good open source tool which is robust enough to handle this case. Automation frameworks like mechanize can't handle the Javascript.
I need this to be run in a graphic-less environment (via cron), so I don't think I can depend on tools such as watir which control standard browsers.
Any language is fine, although a scripting language is preferred.
Suggestions? Can I tap into the browser engines without displaying the browser?
Take a look at WWW::HtmlUnit. It is a Perl module that uses a Java library (included in the Perl module) that makes it easy to automate web pages, even those with JavaScript.
Use webdriver . The API page says you can toggle the visibility.
If webdriver doesn't fit you, you can use COM directly to automate Internet Explorer, you'd just have to read the documentation page on MSDN.
I'm not really sure how they will react to the graphic-less environment though.
Another option would be to use HtmlUnit, which can handle JavaScript, and emulates a browser, so you don't need to worry about interfacing with a real browser.
As for the scripting part, you can use groovy which compiles to bytecode. If you know Ruby, you'll have no trouble picking up groovy. Here's a link that will help PLEAC groovy
This may do what you want: Test Run: Web UI Automation with Windows PowerShell:
Dr. James McCaffrey - March 2008 Here
we show you how to use Windows
PowerShell to create quick and easy UI
test automation for ASP.NET and
classic ASP Web applications.