I found a nice little Javascript prototyping trick that works in
Firefox but doesn't work in Safari
JSDiv.prototype = document.createElement('div');
function JSDiv(inContainer, inStyle)
{
var t = this;
t.setAttribute('id', 1);
t.setAttribute('class', inStyle);
inContainer.appendChild(t);
}
What this allows me to do is treat DOM nodes as script objects which
allows for some really slick Javascript classes. In Safari however I
get the following error on the "setAttribute" function: "TypeError -
Type error"
It doesn't appear that any Javascript hacks in Safari work I tried
this (along with a few other ideas) and got the same error
function foo() {return document.createElement('div');}
JSDiv.prototype = new foo();
The interesting thing is that using the Ajax "bind" function, you can
attach functions to DOM nodes in Safari
function foo() {alert('Hellow World!');
var x = document.createElement('div');
x.sayHello = foo.bind(x);
x.sayHello();
So It's part way there, I just need some way to coerce a script to a
DOM node or pose as a dom node. Can anyone think of a way this could
be done? Either by exposing a Cocoa class method to the Javascript
like this
- (void) createDiv
{
/* some sort of DOM trickery here */
}
Or some other hack?
Thanks for any help
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden