SandboxContents
API Links
Jaxer's secure sandbox lets you load, on your server, pages from other domains and execute the remote page's JavaScript too without giving it access to the Jaxer API or your own server-side code, even though your code has access to their window objects and anything inside them. While you can't visualize these windows (they're on the server after all) you can use them programmatically whether you're:
Since Ajax is so prevalent today in web pages, being able to trigger the Ajax events server-side such that the content added via the Ajax calls is available in a server-side DOM is very handy and can be applied for tasks like search engine optimization and accessiblity modes for your web apps. The Difference between Jaxer.Sandbox and Jaxer.Web.get
Core Features
Getting a Sandbox InstanceThe constructor takes three pieces of information: the URL to load, a query string of data to POST and an options hash specifying how to load this Sandbox; all three are optional and leaving the query string empty/null signals Jaxer to do a GET rather than POST. Tip: Use Jaxer.Util.URL.hashToQuery to build the query string parameter.
You can use
readyState values:
The Sandbox EventsCatch SSL certificate failures inside the SandboxJaxer.Sandbox.OpenOptions allows you to specify a callback function to handle SSL certificate failures in the same way as on server-side XHR requests (Handling SSL Errors). Your callback function is called with the following arguments:
The function should return Catch location changes inside the Sandbox
If the Sandbox's URL is going to changed due to a server HTTP or HTML <meta> tag redirect or from JavaScript code (if allowed by the With Ajax LibrariesThis functionality can work well with Ajax libraries too. For instance, jQuery can take a document object as a parameter when generating a selector, so all the related capabilities and plugins can run against a Sandboxed document as well: var sandbox = new Jaxer.Sandbox();
sandbox.open('http://URL');
var title = $("title", sandbox.document).text();
Sandbox ExamplesLoad Pages Asynchronously and Stream to Browser as Bits ArriveTaken from DOM Scraping with Jaxer part 2
Get Data SecurelyLoads a remote URL in a sandbox, finds all of the h2 elements, and adds them to the body of the requested page.
Get Data Securely (Customized)Using Sandbox to proxy a webpage through JaxerThis code loads a remote webpage (http://www.aptana.com) and serves it through the local jaxer instance. It uses jQuery to rebase any relative urls to fully qualified paths. It demonstrates manipulating the DOM on the sandbox to process a page prior to re-sending through Jaxer.
|
