开发者

Relative CSS URL values with WebKit (Objective-C API)

开发者 https://www.devze.com 2023-03-25 15:12 出处:网络
I want to change the URL\'s of a background-image property in a HTML document. DOMCSSStyleDeclaration *style = domELement.style;

I want to change the URL's of a background-image property in a HTML document.

DOMCSSStyleDeclaration *style = domELement.style;
NSString *imageURL = [style backgroundImage];

Now the imageURL looks something like url(<base URL I've loaded the HTML开发者_开发技巧 with>/image.jpg). But in the HTML source it's url(image.jpg). Now I'd like to change the image.jpg to an other image and still keep the relative path. How do I do that? Because when i set something like url(newImage.jpg) the rendered output looks like url(<base URL I've loaded the HTML with>/newImage.jpg).

May I change something when getting the HTML?

DOMHTMLElement *htmlElement = (DOMHTMLElement*)[document documentElement];
NSString *html = [htmlElement outerHTML];

Or is there an other way how I can set a relative URL in a css attribute?

[style setBackgroundImage:@"url(newImage.jpg)"];


I didn't found anything at all. So I did pars it my self with an NSSCanner

0

精彩评论

暂无评论...
验证码 换一张
取 消