Relative and absolute attributes (src, href)

(And on every other attribute which contains Uniform Resource Identifiers)

Images and src

  1. Test image (src="image.jpg")
  2. Test image (src="/stuff/javascript/attributes-absolute-relative/image.jpg")
  3. Test image (src="http://krijnhoetmer.nl/stuff/javascript/attributes-absolute-relative/image.jpg")

1.src:

1.getAttribute('src'):


2.src:

2.getAttribute('src'):


3.src:

3.getAttribute('src'):


Gecko is very strict on .getAttribute! Probably the same with href on anchors.

Anchors and href

  1. First (href="")
  2. Second (href="/stuff/javascript/attributes-absolute-relative/")
  3. Third (href="http://krijnhoetmer.nl/stuff/javascript/attributes-absolute-relative/")

1.href:

1.getAttribute('href'):


2.href:

2.getAttribute('href'):


3.href:

3.getAttribute('href'):


Gecko is strict again :)


Home - More stuff