Kodenfreuder
2007-May-06 19:31 UTC
Safari vs. Firefox Problem with Attaching Events to Child Window Objects
I''ve written some code, if you can call it that, to open a child
window, and attach events to buttons in the window after it loads.
Getting that done was nightmare just in Firefox, since Prototype never
extended any of the elements it processed (not that it was supposed
to, it just took me a while to figure out how to use the less magical
methods. :), but in Safari the buttons are never "activated." We only
NEED Firefox to work, but I would like to be able to use it Safari. Is
this a shortcoming in Safari, or did I misuse Prototype somehow? No
messages appear in Safari''s JS debug console.
Much thanks. - V
JS
------
function runTest () {
Event.observe($(''popIt''), ''click'',
PopupFlyerOpen);
Event.observe(window, ''unload'', PopupFlyerCLose);
}
function PopupFlyerOpen () {
PopupFlyerCLose();
var url = ''file:///Users/typeo/Desktop/aptana/workspace/FEF\ Ajax/
testLinks.html'';
var w = 700;
var h = screen.height - 100;
var l = Math.round((screen.width - w) / 2);
var winprops =
''height=''+h+'',width=''+w+'',left=''+l+'',top=''
+ 1 +
'',scrollbars=yes,resizable=yes'';
fWin = window.open(url, ''fwin'', winprops);
Event.observe(fWin, ''load'', function () {
Element.getElementsByClassName(fWin.document.getElementById(''remoteControl''),
''remoteButton'').each(function (o) { Event.observe(o,
''click'', function
(e) { linkClicked(e, o) }) }) });
}
function PopupFlyerCLose () {
if (typeof(fWin) != ''undefined'') { fWin.close(); }
// try { if (fWin) { fWin.close(); } } catch (e) {}
// Try.these( function () { fWin.close(); });
}
function linkClicked (e, o) {
Event.stop(e);
// alert(Element.readAttribute(o,''value''));
alert(Element.inspect(o));
}
Event.observe(window, ''load'', runTest);
------
Launch button HTML
----
<body>
<button id="popIt">Open Child</button>
</body>
----
Remote Buttons for New Window HTML
------
<body>
<div id="remoteControl">
<button class="remoteButton" name="ajax"
value="1">1</button>
<br /><br />
<button class="remoteButton" name="ajax"
value="2">2</button>
<br /><br />
</div>
</body>
------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---