1 |
/* |
2 |
Open linked document with Live DOM Viewer, for WinIE |
3 |
|
4 |
See also: <http://suika.fam.cx/gate/2005/sw/Bookmarklet#anchor-53> |
5 |
|
6 |
License: Public Domain |
7 |
*/ |
8 |
|
9 |
window.OpenInLiveDOMViewer = function (uri) { |
10 |
var xhr = window.XMLHttpRequest |
11 |
? new XMLHttpRequest () |
12 |
: new ActiveXObject ('Microsoft.XMLHTTP'); |
13 |
xhr.open ("GET", uri, false); |
14 |
xhr.send (null); |
15 |
location.href = |
16 |
'http://software.hixie.ch/utilities/js/live-dom-viewer/?' |
17 |
+ encodeURIComponent (xhr.responseText); |
18 |
}; |
19 |
|
20 |
var links = []; |
21 |
var linksLength = document.links.length; |
22 |
for (var i = 0; i < linksLength; i++) { |
23 |
links[i] = document.links[i]; |
24 |
} |
25 |
|
26 |
for (var i = 0; i < linksLength; i++) { |
27 |
var link = links[i]; |
28 |
var container = document.createDocumentFragment (); |
29 |
container.appendChild |
30 |
(document.createTextNode (' [')); |
31 |
var a = container.appendChild |
32 |
(document.createElement ('a')); |
33 |
a.href = link.href; |
34 |
a.appendChild (document.createTextNode ('Live DOM Viewer')); |
35 |
a.onclick = function () { |
36 |
window.OpenInLiveDOMViewer (this.href); |
37 |
return false; |
38 |
}; |
39 |
container.appendChild |
40 |
(document.createTextNode (']')); |
41 |
link.parentNode.insertBefore |
42 |
(container, link.nextSibling); |
43 |
} |