llamatron
09-06-2003, 05:33 AM
I was using the following code supplied by the Moderator of this board Pyro (http://forums.webdeveloper.com/showthread.php?s=&threadid=16108) to find a certain value in a web pages HTML code:
function getid(){
code = document.getElementsByTagName("html")[0].innerHTML;
results = code.match(/member_id=(\d*)&/g);
for (i=0;i<results.length;i++) {
value = results[i].match(/member_id=(\d*)&/);
alert (value[1])
}
}
This works fine however the problem is that I need to find the code in a popup window not the main window where this code sits (the popup window is an external page i have no control over).
So I tried this :
function newin(){
newWindow = window.open('http://www.myurl.com', 'form_target','width=700, height=500, scrollbars=no,menubar=no,status=no,resizable=no,toolbar=no, titlebar=no,location=no,directories=no');
setTimeout("getid();",5000);
}
function getid(){
code = newWindow.document.getElementsByTagName("html")[0].innerHTML;
results = code.match(/member_id=(\d*)&/g);
for (i=0;i<results.length;i++) {
value = results[i].match(/member_id=(\d*)&/);
alert (value[1])
}
}
But I just get a javascript error. I know I can control newWindow in the getid() function because if i put the line newWindow.close() in getid() it closes the popup. So why can't i refer to it in the same way when running Pyro's code?
The only thing I can think of is the popup window page is not getting sufficent time to load fully, but the setTimeout function should avoid this right? Please help. Thanks
function getid(){
code = document.getElementsByTagName("html")[0].innerHTML;
results = code.match(/member_id=(\d*)&/g);
for (i=0;i<results.length;i++) {
value = results[i].match(/member_id=(\d*)&/);
alert (value[1])
}
}
This works fine however the problem is that I need to find the code in a popup window not the main window where this code sits (the popup window is an external page i have no control over).
So I tried this :
function newin(){
newWindow = window.open('http://www.myurl.com', 'form_target','width=700, height=500, scrollbars=no,menubar=no,status=no,resizable=no,toolbar=no, titlebar=no,location=no,directories=no');
setTimeout("getid();",5000);
}
function getid(){
code = newWindow.document.getElementsByTagName("html")[0].innerHTML;
results = code.match(/member_id=(\d*)&/g);
for (i=0;i<results.length;i++) {
value = results[i].match(/member_id=(\d*)&/);
alert (value[1])
}
}
But I just get a javascript error. I know I can control newWindow in the getid() function because if i put the line newWindow.close() in getid() it closes the popup. So why can't i refer to it in the same way when running Pyro's code?
The only thing I can think of is the popup window page is not getting sufficent time to load fully, but the setTimeout function should avoid this right? Please help. Thanks