Results 1 to 8 of 8

Thread: Load external Page

  1. #1
    Join Date
    Jan 2012
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Load external Page

    Hello.
    I want to load an external page(ex: http://www.google.com), but i want to make it load automatically, not clicking any button. I want it to load like if no one can see that it loads, by example my web is www.mywebpage.com but the page that i want to be loaded does not takes redirect www.mywebpage.com to it. www.mywebpage.com stands there.
    Something like an <iframe> but i dont want iframes, dont ask me why, but not iframes.
    How can i do this?

    Thanks!
    Last edited by Vaonline; 02-20-2012 at 02:17 AM.

  2. #2
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,524
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    If you have php installed you can just use this

    Code:
    <?php
    include 'pathtofile';
    ?>
    Just replace the yellow bit with the path to the file. Remember, the page you are trying to include must be on your server, so you can't include google or anything like that(Correct me if I'm wrong).

    Another method is ajax.

    Code:
    <script type="text/javascript">
    function HttpRequest(url){
    var pageRequest = false //variable to hold ajax object
    /*@cc_on
       @if (@_jscript_version >= 5)
          try {
          pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
          }
          catch (e){
             try {
             pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
             }
             catch (e2){
             pageRequest = false
             }
          }
       @end
    @*/
    
    if (!pageRequest && typeof XMLHttpRequest != 'undefined')
       pageRequest = new XMLHttpRequest()
    
    if (pageRequest){ //if pageRequest is not false
       pageRequest.open('GET', url, false) //get page synchronously 
       pageRequest.send(null)
       embedpage(pageRequest)
       }
    }
    
    function embedpage(request){
    //if viewing page offline or the document was successfully retrieved online (status code=2000)
    if (window.location.href.indexOf("http")==-1 || request.status==200)
       document.write(request.responseText)
    }
    
    HttpRequest("pathtofile") //include "external.htm" onto current page
    </script>
    Just replace the bit in yellow with the path to the file. Again, the page you are trying to include must be on your server, so you can't include google or anything like that(Correctme if I'm wrong).

    The ajax code is from this site.
    Hope this helps
    Last edited by keyboard; 02-20-2012 at 03:18 AM. Reason: Added a space

  3. #3
    Join Date
    Jan 2012
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Since my web host does not allows uploads, i cant have a server to upload.
    Any other? : /

  4. #4
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,524
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    i cant have a server to upload.
    Oops, sorry if I confused you.
    Your webhost is a server. Does that make more sense?
    If your webhost has php installed(you'd have to check with them) you can use either of the codes. If it dosen't have php installed, the second one may work.

    Edit: If your server dosn't allow uploads, how do you get your webpages onto the server/webhost?

  5. #5
    Join Date
    Jan 2012
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    First of all, thanks for your help. As you can see, i am barely a newbie on this.
    The webhost itselfs uploads the pages, it is a free service, i mean i only write a new "entry" and click save and there it is but i dont upload documents or something.
    I tried those 2 codes, and they didnt work. When im "editing" (making a new entry/publication) there is only one feature "html" and of course, the normal text. So, it seems like no php right?.

    I am replacing "pathtofile" writing the url of a web page, because the "file" is in a external webpage (yes because i cant upload files into my webhost), but it seems that it does not loads the webpage, does not work.

    Another way that would be useful for me is...
    Ill explain, im trying to load a html iframe several times, so i repeat the iframe code many times. But my web host editor/entry publisher only stands like 500 characters, so it cuts the code.
    So, how can i load this html iframe many many times without repeating the iframe code one, and one and one more time? I have tried refreshing iframe but does not work for me.

    As you can see, all i want is to load this code several times, from an external page or... from my page but with a more little code so i dont need an external page.

    Do i explain myself?
    Thanks, any help is welcome.

  6. #6
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,524
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    HTML Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <script type="text/javascript" src="jFunc.js"></script>
    <script type="text/javascript">
    function ChangeSrc(element)
    {
    document.getElementById('frame').src = element;
    }
    </script>
    </head>
    <body>
    <iframe src="http://www.dynamicdrive.com/forums/" id="frame" height="500px" width="1500px">If you can see this, your browser doesn't support IFRAME</iframe>
    <input type="button" onclick="ChangeSrc('http://www.dynamicdrive.com/')">
    </body>
    </html>
    When you click the button ChangeSrc('http://www.dynamicdrive.com/') is run. The url for Dynamic Drive is sent to the function, ChangeSrc() as a parameter, and is then specified as the src attribute for the iframe with the id of frame. Everytime you want to change the url, you call the ChangeSrc() function and inbetween the two brackets, write the url to include like such ChangeSrc('http://www.google.com');. This should work on any web server that supports javascript.

  7. #7
    Join Date
    Jan 2012
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks again, but this is about refreshing an iframe again. As i said, it does not work for me as it is not better than writing the iframe like 50 times. And in your code, you have to click and i want it to do it automatically every some seconds.
    Can you tell me that code but with automatically refresh every some "seconds" to see how it goes or something more? ;ss
    If you have more solutions, more ways, ill be grateful!

  8. #8
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,524
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Try this

    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <script type="text/javascript">
     /*EDIT THIS STUFF*/
     var url=new Array();
     url[0]="http://www.dynamicdrive.com";
     url[1]="http://www.dynamicdrive.com/forums";
     
     var timeout = 10000;
     /*STOP EDITTING*/ 
     var int=self.setInterval("clock()",timeout);
     var timer = "0";
     var arraylength = url.length;
     function clock() {
     if(timer == arraylength) {
     timer = "0";
     }
     document.getElementById('frame').src = url[timer];
     timer++;
     }
    </script>
    </head>
    <body>
    <iframe src="http://www.dynamicdrive.com/forums/" id="frame" height="500px" width="1500px">If you can see this, your browser doesn't support IFRAME</iframe>
    </body>
    </html>
    This bit (YELLOW IN FULL CODE)

    HTML Code:
     /*EDIT THIS STUFF*/
     var url=new Array();
     url[0]="http://www.dynamicdrive.com";
     url[1]="http://www.dynamicdrive.com/forums";
     
     var timeout = 10000;
     /*STOP EDITTING*/
    Just specify all the urls like this
    url[0]="URL";
    Then add one nmber on for each url. The first one must be zero.
    var timeout = 10000; is the amount of time between the changes. 10000 is ten seconds 1000 is 1 second and so on.

    Hope this helps
    Keyboard1333
    Last edited by keyboard; 02-23-2012 at 09:06 AM.

Bookmarks

Posting Permissions

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