• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 952
  • Last Modified:

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.frames[0].PrintPreview();">Print Preview</a>&nbsp;|&nbsp;<a class="OneLinerHFLink" href="javascript:window.history.go(0-1)"">Revise 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>&nbsp;|&nbsp;First&nbsp;|&nbsp;Previous&nbsp;|&nbsp;<A class="OneLinerHFLink" HREF='javascript:GetNext(51,51)'>Next</A>
&nbsp;|&nbsp;<A class="OneLinerHFLink" HREF='javascript:GetNext(5,5)'>Last</A>
</td>
</tr>

I run this line
WebBrowser1.document.frames(1).execScript 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?
0
GrahamSkan
Asked:
GrahamSkan
  • 7
  • 6
1 Solution
 
DreamMasterCommented:
WebBrowser1.document.Window.Frames[1].execScript GetNext(51,51), "JavaScript"

that should work...

Regards,
Max.
0
 
GrahamSkanAuthor Commented:
The square brackets cause a syntax error, so I've changed them to ().
But I get the same error.
0
 
GrahamSkanAuthor Commented:
(Still 'Sub or Function not defined')
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
DreamMasterCommented:
You are not sure where the function is you said?

Try if  you can even call Webbrowser1.document.window.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.
0
 
GrahamSkanAuthor Commented:
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.frames(1).document.all.length
as does this:
WebBrowser1.document.frames("mainn").document.all.length

but these give error 438 (Object doesn't support this property or method).
WebBrowser1.document.window.frames(1).document.all.length
WebBrowser1.document.window.frames("mainn").document.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.
0
 
DreamMasterCommented:
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.
0
 
GrahamSkanAuthor Commented:
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
0
 
DreamMasterCommented:
Strange..there should be a function somewhere...otherwise it would never work...

Last option to try:

WebBrowser1.document.frames(1).GetNext(51,51)

Regards,
Max.

P.S. Not a problem...I like challenges... ;)
0
 
GrahamSkanAuthor Commented:

Bingo.

This worked OK.

Call WebBrowser1.document.frames(1).GetNext(51, 51)

Should that syntax always work? It is neater than using execScript.
0
 
DreamMasterCommented:
Yes...as long as the reference to the frame is made, you can call any function that's defined in it...

Regards,
Max.
0
 
GrahamSkanAuthor Commented:
Max,
Thanks for your help
Regards, Graham
0
 
James RodgersWeb Applications DeveloperCommented:
>>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.length;x++){
            if(document.links[x].href.indexOf('GetNext')!=-1){
                  alert(document.links[x].href.replace(/javascript:/,""));
            }
      }
</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>
0
 
DreamMasterCommented:
No problem, just glad I could help.. :)

Regards,
Max.
0
 
GrahamSkanAuthor Commented:
Jester_48, thanks for the extra bit of information.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now