Forum Moderators: open

Message Too Old, No Replies

IFRAMES & Javascript.help!

IFRAMES, Javascript, Cross-Site

         

sbritton

5:20 pm on Nov 10, 2007 (gmt 0)

10+ Year Member



Okay...I'm completely confused.

My client has a web application that he subscribes to that is IP sensitive...in otherwords, will only logon from his office.

He wants me to screen-scrape data out of that application and put it in a database for him.

The approach I was thinking about was using Javascript to do the logon, navigation to the data ladden page and scraping from a hidden (or not hidden) IFRAME. I'm happy to use a child window if that works. The catch is it has to be client side since it has to be from a specific machine (not a server outside the domain).

Step 1: Open remote URL in IFRAME
Step 2: Change the form elements for ID & PW in the IFRAME
Step 3: Submit the IFRAME logon form & wait for reponse
Step 4: Click on a specific link on the returned page (gets the report parms)
Step 5: Enter a single data field (in this case SSN) & submit the new form
Step 6: Screen scrape all of the resulting HTML (it is a report)

The problem I'm having is that I can't manipulate the DOM beyond the IFRAME element. In otherwords, the content inside the IFRAME from the datasource simply can not be found or interacted with.

I have a feeling this has something to do with Cross-Site scripting and IE 7's attempt to cut down on phishing.

My test code works well if the main window and the sub-window are from the same domain...but once the sub-sindows content (via src='') is from a different domain, nothing.

IDEAS PLEASE!

Is there something I can do to the browser settings to work around this?
Is there a different browser that doesn't have this limitations?
Is there a different approach such as using child windows?

SAMPLE:

If the SRC is the same domain as the sample code...it works.

<html>
<head>
<script language="javascript">
function getinfo() {
//Gets object reference of the IFRAME so I can work with it
myiframe = window.parent.top.document.getElementById("myifram e");
alert ("Iframe Object:"+myiframe);
//Show src of iframe
alert ("Ifram SRC:"+myiframe.src);
//Will show the value of the first field in the first form
alert (myiframe.document.forms[0].elements[0].value);
}
</script>
</head>
<body>
<a href="#" onclick="getinfo()">Show IFRAME Info</a>
<br><br>
<iframe src="http://www.msn.com" width="700" height="400" id="myiframe"></iframe>
</body>
</html>

daveVk

2:55 am on Nov 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE options - security - Access data sources across domains? May be relevent