Here is some sample code which works in all browsers I've tested, but
errors in Opera:

                <title>Opera test</title>
                <script src="prototype.js" type="text/javascript"></script>
                <script type="text/javascript">
Element.addMethods("DIV", {
        divOperaTest: function(e) { window.alert("Test Successful (" +
e.innerHTML + ")"); }
document.observe("contentloaded", function() {
        $$("div").each(function(a){ a.divOperaTest(); });
        <div>Test Div</div>
        <div>Test Div 2</div>

Changing the line which reads:
        $$("div").each(function(a){ a.divOperaTest(); });

to read:
        $$("div").each(function(a){ $(a).divOperaTest(); });

Makes it work just fine...but I'm wondering why it's
necessary...doesn't each() pass in the extended element already (and
the $$() should definitely be extended already as well)...

I don't know if this is a bug in Opera, in Prototype, or in my own
logic...I'm willing to accept that it is any (or all) of the above.

For now, I can just do $() around my divs...though I would like to
understand the reasoning why...

Here is the error console from within Opera (btw - this is the
prototype 1.6 pre-release)

Event thread: dataavailable
name: TypeError
message: Statement on line 6: Type mismatch (usually a non-object
value used where an object is required)
  Line 6 of inline#1 script in file://users/ntoone/test.html
  Line 584 of linked script file://users/ntoone/prototype.js
    iterator(value, index++);
  Line 831 of linked script file://users/ntoone/prototype.js
  Line 585 of linked script file://users/ntoone/prototype.js
    this._each((function (value)
  iterator(value, index++);
  Line 6 of inline#1 script in file://users/ntoone/test.html
    $$("div").each((function (a)
  Line 3867 of linked script file://users/ntoone/prototype.js, event);
  At unknown location
    [statement source code not available]

You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to