On Thu, Feb 17, 2011 at 12:05 PM, Steve K Speicher <[email protected]> wrote:
> I believe there was some goal to keep the samples "clean" by just using
> standard HTML/JS/DOM and not put browser-specific checks in (hard to draw
> the line where to stop with this).

Yes, that is a valid concern. I think we can make some minor changes
and improve things a bit.


> I'm fine either way though, as the reality is people will snag these and
> want to use them.  Perhaps it would be good to attach a more complete
> example to the spec (provide a reference to) or handle this with other
> supporting material, which we tried to do with IBM Developer Works
> articles, etc.

I have expanded the existing example to work on IE and have tested
successfully on Chrome, Firefox and Safari. I had to work around two
IE related issues:

   The "use attachEvent on IE" issue
   http://bugs.dojotoolkit.org/ticket/9609

   The "can't set iframe name via JavaScript on IE" issue
   http://stackoverflow.com/questions/2138564/dynamic-iframe-ie-name-issue


Here's the new example code:

    var pickerURL = ... // URL of Provider's Delegated UI Dialog
    var returnURL = ... // Consumer's Return URL

    var frame = document.createElement('iframe');

        function windowNameProtocol() {
                
                // Step #1: create iframe with fragment to indicate protocol
                // Step #2: set the iframe's window.name to indicate the Return 
URL
                if (ie > 0) {
                        frame = document.createElement('<iframe name=\'' + 
returnURL + '\'>');
                } else {
                        frame = document.createElement('iframe');               
        
                        frame.name = returnURL;
                }
                frame.src = pickerURL + '#oslc-core-windowName-1.0';
                frame.width = 450;
                frame.height = 300;

                displayFrame(frame);

                // Step #3: listen for onload events on the iframe
                var ie = window.navigator.userAgent.indexOf("MSIE");
                if (ie > 0) {
                        frame.attachEvent("onLoad", onFrameLoaded);
                } else {
                        frame.onload = onFrameLoaded;
                }
        }

        function onFrameLoaded() {
                try { // May throw an exception if the frame's location is 
still a
different origin
                
                        // Step #4: when frame's location is equal to the 
Return URL
                        // then read response and return.
                        if (frame.contentWindow.location == returnURL) {
                                var message = frame.contentWindow.name;
                                destroyFrame(frame);
                                handleMessage(message);
                        }
                
                } catch (e) {
                        // ignore: access exception when trying to access 
window name
                }
        }

I plan to replace the existing example with the above this week.

As usual, feedback is most appreciated.

Thanks
- Dave

Reply via email to