Solved

Search page output with JavaScript or VBScript?

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
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 …
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

626 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