Solved

Search page output with JavaScript or VBScript?

Posted on 2003-10-30
5
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

739 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