Solved

Search page output with JavaScript or VBScript?

Posted on 2003-10-30
5
201 Views
Last Modified: 2011-09-20
I have created a form which passess the necessary values to an already existing page which resides on another server in our company which I do not have access to modify.  The page is hidden in an invisible iframe so the users do not know that the process is running.

I am able to pass it the required information for it to run its processess to completion, however I don't know if they were successful.  I am looking for a way to search the result page for the words "success" or "failed" which appear in the body of the output when the processes are complete.

I have tried the following script, but it does not work for outside pages (ex: try setting an iframe called 'inside' to this page and run it). It gives the "Access denied" error.

function verifySuccess(str)
{
      var txt, found;
      txt = this.top.test.document.body.createTextRange();
      found = txt.findText(str);

      if (found)
      //when verified, continue with program
      {      processSucceeded();      }
      return false;
}

function checkIt()
{
      var result = verifySuccess('Did it work');
      //if unsuccessful after 90 seconds, consider it failed
      setTimeout("resetFailed()",90000);
      if (result == false)
      {      setTimeout("checkIt()",5000);      }
}


When viewing the results page in IE, if you press ctrl+F or go to Edit...Find (on this page), it finds the "success" or "failed" message.  Is there a way to use JavaScript, VBScript, or anything else to run IE's find program?
0
Comment
Question by:NorvilleR
  • 2
5 Comments
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9653893
Hi,

  'access denied' means just that

  instead of writing out success/failure, try setting a variable true/false  and then testing the variable's state/existence/value.  I suspect that also may fail, and that you will either have to get 'signed permissions' or do this server-side

Vinny
0
 

Author Comment

by:NorvilleR
ID: 9664442
I completely understand the 'access denied' part.  That is not my question.  As the question states, I currently have no way of accessing the variables from the existing program.  My scripts simply automate the process of filling in the necessary fields to perform the process.

What I am looking for is a way to search the text that is displayed on the response page.  This page says whether or not the process completed successfully.  All I want to do is use some type of search, like the one built into IE (edit, find), to search the page for that word.
0
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 250 total points
ID: 9664794
Hi,

  The reason your code fails (as well as the suggestion I made regarding a var) is that you cannot access any part of the DOM  -- alert(frameName.document) gives the error.  There is no way to do it in javascript.  Any 'find in page' script requires having access to the DOM.

Sorry, but you will have to do this server-side, with permissions

Vinny
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now