Javascript Copy Page Contents

Discussion in 'JavaScript' started by AT-XE, May 7, 2009.

  1. #1
    Hey there DPers,
    I was struggling with this for days (I'm new to JavaScript) so, I was thinking if I could ask your help on this topic. I basically want to create a function in javascript that will return the contents of a document on the web with the "url" parameter so that I can then call it with the document.write function like on the example below:

    var currentTime = new Date()
    var sec = currentTime.getTime()/1000
    var cont = ajaxinclude('http://www.domain.com/timezone.php?time='+sec)
    document.write(cont)
    Code (markup):
    Thank you,
    -AT-XE
     
    AT-XE, May 7, 2009 IP
  2. JavaScriptBank.com

    JavaScriptBank.com Peon

    Messages:
    141
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can not use AJAX for fetching data from different domains
     
    JavaScriptBank.com, May 9, 2009 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    This can be done easily server-side, but I'm not sure of any way that it can be done client side, most browsers won't allow it.
     
    camjohnson95, May 9, 2009 IP
  4. AT-XE

    AT-XE Peon

    Messages:
    676
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I am trying to fetch data from my domain, on which the javascript will also be run.

    Basically i want to put information inside a server-side script that is gathered by client side (e.x: the allowance of cookies, screen resolution etc).
     
    AT-XE, May 30, 2009 IP