---
title: "url(withAttributeString:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/domdocument/url(withattributestring:)"
---

# url(withAttributeString:)

Constructs a URL given an attribute string.

## Declaration

```swift
func url(withAttributeString string: String!) -> URL!
```

## Parameters

- `string`: The HTML attribute string to convert.

## Return Value

Return Value An NSURL object containing an absolute URL derived from the specified attribute string.

## Discussion

Discussion This method constructs a URL given the string value of an element attribute. Examples include the href attribute of a DOMHTMLAnchorElement object, or the src attribute of a DOMHTMLImageElement object. This method only applies to attributes that refer to URLs. This method is similar to init(string:) in the NSURL class, except that URLWithAttributeString: handles relative URLs automatically based on the current document’s location.
