Findiing IP address Using Java Script

Discussion in 'JavaScript' started by i_am_dhaval, Dec 23, 2009.

  1. #1
    i need java script which i add in my html page when user visit that page then they see his Ip address in my page.

    please help me
     
    i_am_dhaval, Dec 23, 2009 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    And why do you want to get the ip address by javascript??
     
    s_ruben, Dec 23, 2009 IP
  3. i_am_dhaval

    i_am_dhaval Well-Known Member

    Messages:
    1,364
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #3
    i needs ad in html page that is why

    is any other way?
     
    i_am_dhaval, Dec 23, 2009 IP
  4. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #4
    The html pages don't support php on your server??
     
    s_ruben, Dec 23, 2009 IP
  5. i_am_dhaval

    i_am_dhaval Well-Known Member

    Messages:
    1,364
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #5
    not support php
     
    i_am_dhaval, Dec 27, 2009 IP
  6. styleg

    styleg Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Here you go:

    <script language="JavaScript">
    VIH_BackColor = "palegreen";
    VIH_ForeColor = "navy";
    VIH_FontPix = "16";
    VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%";
    VIH_DisplayOnPage = "yes";
    </script>
    <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script>
     
    styleg, Dec 27, 2009 IP
  7. i_am_dhaval

    i_am_dhaval Well-Known Member

    Messages:
    1,364
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    138
    #7
    the main server using php which original hosted this code

    if that site or host is down then it will not work for me.

    i hope you understand.

    please anybody give the proper solution
     
    i_am_dhaval, Dec 28, 2009 IP
  8. wgcom

    wgcom Peon

    Messages:
    157
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    you cant access ip address of the client using javascript.
    you can try to use shtml if you dont have php on server.
    i think server side includes installed by default in apache...
     
    wgcom, Jan 1, 2010 IP
  9. QuackWare

    QuackWare Member

    Messages:
    245
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    35
    #9
    QuackWare, Jan 1, 2010 IP
  10. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #10
    You can not find the IP of the user via Javascript. Javascript is client side and not server side. You will need to make an Ajax call (or have it preloaded) that get's you the IP to use in Javascript.
     
    ThePHPMaster, Sep 21, 2013 IP
  11. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #11
    Or create it in the markup BEFORE pageload is done, since the code to do that client side would be a waste of time and bandwidth... and in fact would be an idiotic solution to it.

    No PHP you say, what idiotic halfwit hosting are you on then? Seriously... If PHP isn't available, how about ASP? SSI/SHTML? PERL? At least one of those should be available, if not your hosting is rubbish not worth paying for.

    Because really, this is the type of thing that has no business client-side in javascript.
     
    deathshadow, Sep 21, 2013 IP