Pages created in iframe srcdoc attribute #93
Description
It is useful sometimes to create the HTML text for an iframe in Javascript and send it to the iframe in the srcdoc attribute. This is most frequently used for self-contained HTML but the document can legitimately access remote resources, and for this purpose HTML provides the element so that relative links in the document are resolved with respect to some external absolute path, rather than with respect to the srcdoc text which would be meaningless.
lab.js requires to know the absolute path to the root of its client document, and captures it in the 'rootpath' variable.
Unfortunately lab.js is not sensitive to this particular use case and finds the rootpath simply by looking at location.href, which doesn't return anything useful for a srcdoc, and in fact causes a Javascript exception.
I haven't worked out a robust fix for this but substituting:
root_page = document.getElementsByTagName("base")[0].href
for
root_page = /^[^?#]*//.exec(location.href)[0]
in line 19 of V2.0.3 source succeeds when the other fails, and vice versa.
Obviously the HTML text you create for your srcdoc has to contain an appropriate <base> element in its <head>,