How Do I Retrieve url in javascript?

Discussion in 'JavaScript' started by it career, May 8, 2007.

  1. #1
    I mean given an url, I need to write a function get so that
    content= get(url)
    The content needs to contain the content of the website url.
     
    it career, May 8, 2007 IP
  2. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #2
    content = window.location.toString();
     
    frankcow, May 8, 2007 IP
  3. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #3
    Thanks, but how do I retrieve content of say domain.com ?
     
    it career, May 8, 2007 IP
  4. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #4
    content? I don't understand the question...
     
    frankcow, May 8, 2007 IP
  5. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #5
    say domain.com has a index.htm, now when I say get("domain.com")
    it should retrieve the content of index.htm e.g.
    
    <html>
    <body>
    content of domain.com/index.html
    
    Code (markup):
     
    it career, May 8, 2007 IP
  6. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #6
    If the script is on a page obtained from domainA.com, with an iframe from domainB (like AdSense ads), your javacript CAN'T get elements from domainB.

    EDIT: Sorry I didn't read your last post.
    So, do you want to get the url (as said on thread title) or the content (as said on your last post) ?
     
    ajsa52, May 8, 2007 IP
  7. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #7
    Get the content of another domain/index.html, so I need to do it in php or perl?
     
    it career, May 8, 2007 IP
  8. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #8
    yes, yes you do
    javascript prevents cross-site scripting (now)
     
    frankcow, May 8, 2007 IP