www.webdeveloper.com
Results 1 to 4 of 4

Thread: How to get a different site's entire page in a string?

  1. #1
    Join Date
    Nov 2005
    Location
    India
    Posts
    336

    How to get a different site's entire page in a string?

    I want to get a different page's entire site in a string so that I can search to see if a certain string is present.

    I know var str = document.body.innerHTML will give the actual page that the javascript is in.

    But i don't want www.example.com, I want www.example.com/page1. Then I want to use the results of the search on www.example.com.

    Thanks!

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    http://www.webdeveloper.com/forum/sh...d.php?t=241738

    Same concept, different file type.

    ^_^

  3. #3
    Join Date
    Nov 2005
    Location
    India
    Posts
    336
    Thanks! and sorry for not looking at that first.

    However, I have come to the same conclusion as Okham did in that post. I don't quite get it. I tried to implement it but its not working.

    Here is what I have:

    Code:
    <HTML>
    <HEAD>
    
    <b><h1><center>Welcome to my Page!</b></h1></center>
    
    </HEAD>
    <BODY>
    
    <p><a href="Check1.html">Page 1</a></p>
    <p><a href="Check2.html">Page 2</a></p>
    
    <p>The first site is: </p>
    <script type="text/javascript">
    
    var sURL = Check1+".html";
    oRequest.open("GET",sURL,false);
    oRequest.setRequestHeader("User-Agent",navigator.userAgent);
    oRequest.send(null)
    if (oRequest.status==200) var str = oRequest.responseText;
    else alert("Error executing XMLHttpRequest call!");
    var result = str.search(/down/i);
    		// I want to queury Check1.html to see if "down" is present, and then
    		// display an image accordingly. What I have here does not work.
    
    if(result == -1)
    // if "down" is not found, then the site is up.
    {
    	document.write('<img src="Up.png" width ="100" height ="100" alt="Error"/>');
    }
    else
    // if "down" is found, then the site is down.
    {
    	document.write('<img src="Down.png" width ="100" height ="100" alt="Error"/>');
    }
    
    </script>
    
    <p>The second site is: </p>
    <script type="text/javascript">
    // if the word "up" is found on "Check_Down.html" then display "up.jpg"
    // else if the word "down" is found on "Check_Down.html" then display "down.jpg"
    </script>
    
    
    </BODY>
    </HTML>
    Please take a look at my code. There are comments where I having trouble.

    Don't get me wrong, I want to learn how it works, but more specific help would be greatly apprciated.

    Thanks!

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    var sURL = Check1+".html"; // This isn't the URL to your file - this is a relative URL path to a variable that doesn't exist (it's undefined) + ".html"
    sURL = "http://yourdomain.com/Check1.html"; // or something like that..

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles