GrahamSkan
asked on
Screenscrape: referenced JavaScript procedure missing from HTML
I am trying to drive a screenscraping program and have problem with a collected list. If the list is too long for the listing page, a First, Previous, Next, Last series of links is displayed to allow the user to navigate the list.
The links refer to Javascript procedures.
<tr class="OneLinerHFLText">
<td width="30%" colspan="30" align="left" valign="top" style="padding-top:2" >
<a class="OneLinerHFLink" HREF="javascript:top.frame s[0].Print Preview(); ">Print Preview</a> | <a class="OneLinerHFLink" href="javascript:window.hi story.go(0 -1)"">Revi se Search</a></td>
<td width="70%" colspan="70" align="right" valign="top" style="padding-top:2" >
Listings <span Class="PrintHidden">1 - 50 of 54 </span> | First& nbsp;|&nbs p;Previous |&nb sp;<A class="OneLinerHFLink" HREF='javascript:GetNext(5 1,51)'>Nex t</A>
| <A class="OneLinerHFLink" HREF='javascript:GetNext(5 ,5)'>Last< /A>
</td>
</tr>
I run this line
WebBrowser1.document.frame s(1).execS cript GetNext(51, 51), "JavaScript"
and I get 'Sub or Function not defined' with 'GetNext' highlighted.
Certainly I can't find that javascript procedure in the HTML on the page which has two frames and uses stylesheets. Where could it be and, more importantly, how can I call it?
The links refer to Javascript procedures.
<tr class="OneLinerHFLText">
<td width="30%" colspan="30" align="left" valign="top" style="padding-top:2" >
<a class="OneLinerHFLink" HREF="javascript:top.frame
<td width="70%" colspan="70" align="right" valign="top" style="padding-top:2" >
Listings <span Class="PrintHidden">1 - 50 of 54 </span> | First&
| <A class="OneLinerHFLink" HREF='javascript:GetNext(5
</td>
</tr>
I run this line
WebBrowser1.document.frame
and I get 'Sub or Function not defined' with 'GetNext' highlighted.
Certainly I can't find that javascript procedure in the HTML on the page which has two frames and uses stylesheets. Where could it be and, more importantly, how can I call it?
ASKER
The square brackets cause a syntax error, so I've changed them to ().
But I get the same error.
But I get the same error.
ASKER
(Still 'Sub or Function not defined')
You are not sure where the function is you said?
Try if you can even call Webbrowser1.document.windo w.frames(1 ) at all...
Also you can view the source I take it? If so you might reference to the frame using it's name...
Regards,
Max.
Try if you can even call Webbrowser1.document.windo
Also you can view the source I take it? If so you might reference to the frame using it's name...
Regards,
Max.
ASKER
Hi Max.
I've looked in the page source and in the source for both frames. There is only a call, and no source for the script. But it works if I click on it.
This returns 1045
WebBrowser1.document.frame s(1).docum ent.all.le ngth
as does this:
WebBrowser1.document.frame s("mainn") .document. all.length
but these give error 438 (Object doesn't support this property or method).
WebBrowser1.document.windo w.frames(1 ).document .all.lengt h
WebBrowser1.document.windo w.frames(" mainn").do cument.all .length
Yes I can view the source. I can only find the call to the script in the HREF, not the script itself. I have looked in the other frame as well.
I've looked in the page source and in the source for both frames. There is only a call, and no source for the script. But it works if I click on it.
This returns 1045
WebBrowser1.document.frame
as does this:
WebBrowser1.document.frame
but these give error 438 (Object doesn't support this property or method).
WebBrowser1.document.windo
WebBrowser1.document.windo
Yes I can view the source. I can only find the call to the script in the HREF, not the script itself. I have looked in the other frame as well.
Well...then that's likely the source of your problems...how about the frameset itsself? Could be the function is defined in there...
Regards,
Max.
Regards,
Max.
ASKER
Hi Max,
Thanks for you help and interest so far.
Unless there is some magic method of getting javascript from the server, logic says that it must exist on the page somewhere, or perhaps that's just dummy code and the real action is hidden somehow.
This is the page source obtained using the Firefox browser. Is that what you mean, or is there a frameset object that I should get.
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<title>MLSAlliance™ Home Page</title>
</head>
<frameset framespacing="0" frameborder="0" border="0" cols="85,*">
<frame name="contents" target="mainn" src="FrameBar4.asp" borderColor="#FFFFFF" marginwidth="0" marginheight="0" scrolling="no" noresize>
<frame name="mainn" src="apps/search/MapServer .asp" marginwidth="0" marginheight="0" borderColor="#FFFFFF">
<noframes>
<body bgcolor="#FFFFFF">
<p>This web page uses frames, but your browser doesn't support them. Please use a browser that supports frames.</p>
</body>
</noframes>
</frameset>
</html>
Graham
Thanks for you help and interest so far.
Unless there is some magic method of getting javascript from the server, logic says that it must exist on the page somewhere, or perhaps that's just dummy code and the real action is hidden somehow.
This is the page source obtained using the Firefox browser. Is that what you mean, or is there a frameset object that I should get.
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.
<title>MLSAlliance™ Home Page</title>
</head>
<frameset framespacing="0" frameborder="0" border="0" cols="85,*">
<frame name="contents" target="mainn" src="FrameBar4.asp" borderColor="#FFFFFF" marginwidth="0" marginheight="0" scrolling="no" noresize>
<frame name="mainn" src="apps/search/MapServer
<noframes>
<body bgcolor="#FFFFFF">
<p>This web page uses frames, but your browser doesn't support them. Please use a browser that supports frames.</p>
</body>
</noframes>
</frameset>
</html>
Graham
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bingo.
This worked OK.
Call WebBrowser1.document.frame
Should that syntax always work? It is neater than using execScript.
Yes...as long as the reference to the frame is made, you can call any function that's defined in it...
Regards,
Max.
Regards,
Max.
ASKER
Max,
Thanks for your help
Regards, Graham
Thanks for your help
Regards, Graham
>>I can only find the call to the script in the HREF, not the script itself. I have looked in the other frame as well
look for a reference in the head, something like
<script language="JavaScript" type="text/javascript" src="path/to/file.js">
this will have teh source javascript
not exactly what you are looking for but might be helpful
<script language="JavaScript" type="text/javascript" src="">
var str="";
for (x=0;x<document.links.leng th;x++){
if(document.links[x].href. indexOf('G etNext')!= -1){
alert(document.links[x].hr ef.replace (/javascri pt:/,""));
}
}
</script>
<script language="VBScript">
for x=0 to document.links.length
if(InStr(document.links(x) .href, "GetNext")) then
msgbox Replace(document.links(x). href, "javascript:", "")
end if
next x
</script>
look for a reference in the head, something like
<script language="JavaScript" type="text/javascript" src="path/to/file.js">
this will have teh source javascript
not exactly what you are looking for but might be helpful
<script language="JavaScript" type="text/javascript" src="">
var str="";
for (x=0;x<document.links.leng
if(document.links[x].href.
alert(document.links[x].hr
}
}
</script>
<script language="VBScript">
for x=0 to document.links.length
if(InStr(document.links(x)
msgbox Replace(document.links(x).
end if
next x
</script>
No problem, just glad I could help.. :)
Regards,
Max.
Regards,
Max.
ASKER
Jester_48, thanks for the extra bit of information.
that should work...
Regards,
Max.