[webkit-dev] Javascript / Obj-c object property mismatch

Rudi Sherry rsherry at adobe.com
Thu Oct 26 08:47:30 PDT 2006


I'm working with a WebView where I use DOM object manipulation in  
objective-c combined with javascript.

I have the dom document and I add an object with some attributes like  
this:

	DOMNodeList *list = [ domDoc getElementsByTagName: @"BODY" ];
	DOMNode *body = [ list item: 0 ];
	myObject = (DOMHTMLObjectElement *) [ [ domDoc createElement:  
@"OBJECT" ] retain ];
	[ myObject setAttribute: @"ID" : @"MyObjectName" ];
	[ myObject setAttribute: @"NAME" : @"MyObjectName" ];
	<snip>
	[ myObject setAttribute: @"command" : @"xxx" ];
	[ body appendChild: myObject ];

In the javascript, I can get the object with this and check its value  
(this is in a javascript function that gets called):

	var myObject = document.body.children['MyObjectName'];
	alert(myObject.command);
	myObject.command = "abcdef";
	alert(myObject.command);

I have a WebUIDelegate with the runJavaScriptAlertPanelWithMessage  
that prints out the alert value and compares it against myObject:

- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage: 
(NSString *)message
{
	NSLog (@"alert: %@", message);
	NSLog( @"command attribute: %@", [ mSwfObject getAttribute:  
@"command" ] );
}


In the above example, it prints out:

2006-10-26 08:44:29.771 TestInsideWebKit[9235] alert: xxx
2006-10-26 08:44:29.771 TestInsideWebKit[9235] command attribute: xxx
2006-10-26 08:44:29.771 TestInsideWebKit[9235] alert: abcdef
2006-10-26 08:44:29.771 TestInsideWebKit[9235] command attribute: xxx


Why isn't the command attribute changed in the objective-c object  
when it's changed in the javascript function?  It must be the same  
object since it started as 'xxx'.

Any help would be appreciated,

Thanks,
Rudi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/webkit-dev/attachments/20061026/727a48b7/attachment.html


More information about the webkit-dev mailing list