Get the HTML of another page

Discussion in 'JavaScript' started by bamb0lin, Oct 25, 2006.

  1. #1
    How can I get the HTML of another page using javascript so that I can add it to the current page ;-) Thanks
     
    bamb0lin, Oct 25, 2006 IP
  2. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Morishani, Oct 25, 2006 IP
  3. bamb0lin

    bamb0lin Well-Known Member

    Messages:
    401
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Thanks I though there was a function in javascript that will do the job ;-)
     
    bamb0lin, Oct 25, 2006 IP
  4. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thats preety easy if you have a little knowledge in js, and in "googleing" :p
     
    Morishani, Oct 25, 2006 IP
  5. LaPoChE

    LaPoChE Active Member

    Messages:
    198
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    Ajax is realy great. I recommend using Ajax on your sites. Go thru this tutorial, it should only take about 15 minutes and you will have a good idea how it works. Its pretty simple.

    http://www.w3schools.com/ajax/default.asp
     
    LaPoChE, Oct 25, 2006 IP
  6. bamb0lin

    bamb0lin Well-Known Member

    Messages:
    401
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #6
    What I Hate about ajax is that it makes your website SEO enemy
     
    bamb0lin, Oct 25, 2006 IP
  7. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hell no if you use it in the right way, lets take the example of taking HTML content from other page, you should create for that two modes :

    1. Client side support js - the server side will only return the content without the header and footer, the client side will show it in some div.

    2. Client side dont support js - the page willl move to the page which the server return the full page

    To do this you'll have to put your links like that :

    <a href="full_page1.html" onclick="get_page('non_full_page1.html'); return false;">Go to page1</a>
    HTML:
    In that case, if the client side don't support js, it will go to "Full_page1.html", if not, it will return "non_full_page1.html" to the div, Of course, with the appropriate function :)

    All of this can be done with the "return false;" in the onclick event .

    Keep sites accessible even with ajax :)
     
    Morishani, Oct 25, 2006 IP