Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting an attribute to a DOMElement



You need to add it to the document after creating it;
here's an example:

DOMDocument *doc=[frame DOMDocument];
DOMNode *link=[doc createElement:@"a"];
[link
setAttribute:@"href":@"http://www.yoursite.com/";];
DOMNodeList *body=[doc getElementsByTagName:@"body"];
[[body item:0] appendChild:link];

if you want to add script code, say to add a new
function or something, you would need to call
evaluateWebScript instead:

WebScriptObject *scriptObject=[[frame webView]
windowScriptObject];
[scriptObject evaluateWebScript:@"new
Function(.......)"];

--- Michael Hanna <email@hidden> wrote:

> I've tried:
> 
> DOMElement *el = [doc createElement:@"SCRIPT"];
> [el setAttribute:@"type" :@"text/javascript"];
> 
> but this isn't reflected in the HTML.
> 
> How do I do this? I see the class DOMAttr, however
> in DOMCore.h, it's  
> not totally clear how to set the name of it. I see
> -setValue: but no - 
> setName:
> 
> once I do that, do I simply make DOMAttr a child of
> 'el' ?
> 
> Michael
> 
> --
> Michael Hanna
> email@hidden
> iChat: michaelkhanna(AIM)
> 
> 
> 
>  _______________________________________________
> 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
> 
> This email sent to email@hidden
> 



	
		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs
 _______________________________________________
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

This email sent to email@hidden

References: 
 >Setting an attribute to a DOMElement (From: Michael Hanna <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.