Posts that engtech is monitoring

Subscribe to Posts that engtech is monitoring 2 posts found

Sep 14, 2007
sizzlemctwizzle 120 posts

Topic: gm_xmlhttprequest to submit form

I got rid of the denied access errors by using contentDocument.open() to give me complete access to the iframe. I can't afford to wait for entire page load with my script.

 
Sep 9, 2007
sizzlemctwizzle 120 posts

Topic: gm_xmlhttprequest to submit form

This was I problem for me to when I wrote this script http://userscripts.org/scripts/show/10682. I wish there was some type of class that would take html and parse it using regular expressions and return it like getelementbyid and getelementsbytagname. The cool thing is that when you load an xml document you can use the DOMParser object, which I did in this script http://userscripts.org/scripts/show/10653. Anyway I use about the same code in the first script I posted, only when I tried to set the body.innerHTML I kept getting denied access to the iframe. So instead I use code more like this (not in a neat class though, sorry):

var url = "url I want to get";
var myframe = document.createElement('iframe');
myframe.src = "about:blank";
myframe.width = "10";
myframe.height = "10";
myframe.id = "myframe";
myframe.style.display = "none";
document.body.appendChild(myframe);
var client = new XMLHttpRequest();
client.open("GET", url);
client.send(null);
client.onreadystatechange = function () {
if (client.readyState==4)
{
if (client.status==200)
{
myframe = document.getElementById('myframe');
document.getElementById('myframe').contentDocument.open();
html = client.responseText.split(/<body[^>]*>((?:.|\n)*)<\/body>/i)[1];
document.getElementById('myframe').contentDocument.write(html);
element = myframe.contentDocument.getElementById(id);
myframe.contentDocument.close();
myframe.src = "about:blank";
}
}
};