source: Dev/branches/rest-dojo-ui/client/dojox/io/tests/windowName.html @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.5 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3<head>
4        <title>Window Name Test</title>
5        <style type="text/css">
6                @import "../../../dojo/resources/dojo.css";
7                @import "../../../dijit/tests/css/dijitTests.css";
8        </style>
9
10        <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true"></script>
11        <script type="text/javascript">
12                var test, testPost;
13                require(['dojox/io/windowName'], function(windowName){
14        //dojox.io.xhrWindowNamePlugin("http://localhost");
15                        test = function(auth) {
16                                var authTarget = auth && document.getElementById("authTarget");
17                                var dfd = windowName.send("GET",{
18                                                        url: prompt("Enter an address to retrieve data from",
19                                                                        auth ? "http://sitepen.com:80/labs/code/secure/dojox/io/tests/testResource.html" : "http://persevere.sitepen.com/Customer/550"),
20                                                        handleAs:"text",
21                                                        authElement: authTarget,
22                                                        onAuthLoad: auth && function(){
23                                                                authTarget.style.display='block';
24                                                        }});
25                                dfd.addBoth(function(result){
26                                        auth && (authTarget.style.display='none');
27                                        alert(result)
28                                });
29                        };
30                        testPost = function(auth) {
31                                var authTarget = auth && document.getElementById("authTarget");
32                                var dfd = windowName.send("POST",{
33                                                        url: prompt("Enter an address to post data to",
34                                                                        "http://persevere.sitepen.com/Customer/"),
35                                                        content:{foo:"bar"},
36                                                        authElement: authTarget,
37                                                        onAuthLoad: auth && function(){
38                                                                authTarget.style.display='block';
39                                                        }});
40                                dfd.addBoth(function(result){
41                                        auth && (authTarget.style.display='none');
42                                        alert(result)
43                                });
44                        }
45                });
46        </script>
47</head>
48<body class="tundra">
49        <h1>Window Name Test</h1>
50        <div id="authTarget" style="display:none; border: 3px solid blue; width: 300px; height:200px;"></div>
51        <p>This page allows you try getting and posting data cross-site and get the response using the window.name protocol.
52        There are two forms of the window.name protocol, the simple direct access protocol, where the resource simply
53        has to set the window.name property. There is also window.name with authorization. In this second variant,
54        the resource page must redirect to the return URL after setting the window.name property. This example page
55        lets you try out both protocols using GET or POST.</p>
56        <button onclick="test()">get data direct</button>
57        <button onclick="testPost()">post data direct</button>
58        <button onclick="test(true)">get data with authorization</button>
59        <button onclick="testPost(true)">post data with authorization</button>
60        </body>
61</html>
Note: See TracBrowser for help on using the repository browser.