Note that there are some explanatory texts on larger screens.

plurals
  1. POIE only javascript error with getElementsByTagName
    primarykey
    data
    text
    <p>I have the following code which works in FF / Chrome</p> <pre><code>var stack = [Array.prototype.slice.call(document.getElementsByTagName("body")[0].childNodes)], nodes, node, parent, text, offset; while (stack.length) { nodes = stack.pop(); for (var i=0, n=nodes.length; i&lt;n; ++i) { node = nodes[i]; switch (node.nodeType) { case Node.ELEMENT_NODE: if (node.nodeName.toUpperCase() !== "SCRIPT") { stack.push(Array.prototype.slice.call(node.childNodes)); } break; case Node.TEXT_NODE: text = node.nodeValue; offset = text.indexOf("[test="); if (offset &gt;= 0 &amp;&amp; text.substr(offset).match(/^(\[test=(\d+)\])/)) { parent = node.parentNode; var before = document.createTextNode(text.substr(0, offset)); link = document.createElement("a"), after = document.createTextNode(text.substr(offset + RegExp.$1.length)); link.appendChild(document.createTextNode(text.substr(offset, RegExp.$1.length))); link.setAttribute("href", "http://example.com/" + RegExp.$2); parent.insertBefore(after, node); parent.insertBefore(link, after); parent.insertBefore(before, link); parent.removeChild(node); stack.push([after]); } } } } </code></pre> <p>Basically what it does is if it finds [test=25] in the page it converts it to a link which points to example.com/25</p> <p>In IE I get the following error: JScript Object Expected on first line:</p> <pre><code>var stack = [Array.prototype.slice.call(document.getElementsByTagName("body")[0].childNodes)], nodes, node, parent, text, offset; </code></pre> <p>This error occurs in both IE7 and IE8.</p> <p>Any help would be appreciated.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload