Solved

Search page output with JavaScript or VBScript?

Posted on 2003-10-30
5
194 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

707 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

16 Experts available now in Live!

Get 1:1 Help Now