#1
  1. No Profile Picture
    rubbish in javascript
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    London
    Posts
    706
    Rep Power
    14

    Unhappy getting javascript printed result passed to another form


    hello

    trying to do what i thought initially would be an easy thing but is proving very difficult... i need to use the following script on a page which returns your location (works 45% of the time so if it does work for you don't panic) according to your ip....

    <script language=\"Javascript\" src=\"http://map.geoup.com/geoup\"></script>

    now bascially thats fine if i was using it on a page which would render to the browser where you see for example...

    "Special welcome to our visitors from London, United Kingdom."

    but of course the source is the code shown above, the file i am using this in is to be read in by another form as a helper script. Now i can use php or whatever but all i ever seem to get back is the code source and never the result as i need.

    i appreciate this is a bit tricky to get your head around but i would appreciate any help and if my explanation is bad ask and i'll try and explain better.

    thanks in advance
    gar
  2. #2
  3. a lazy guy
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Location
    Hong Kong
    Posts
    99
    Rep Power
    14
    hi

    if you are running it under a php, it will ALWAYS return the same location(the location of your web server). Is that the result you expected?

    I bet you want to get the user's location. So, you must execute this on the user's browser.

    i wrote two tiny html for you.
    it open a small window, and get the location message, then you can read the location by pressing the button.
    try this:

    main.html
    ---------------------
    <script>
    AFRAME = window.open("loc.html", "myFrame", "status=no,scrollbars=no,width=1,height=1");
    </script>

    <script>
    function readMsg(myform)
    {
    alert(myform.mymsg.value);
    }
    </script>
    <form name="myform">
    <input name="mymsg" type="hidden">
    <input type="button" onclick="readMsg(this.form)" value="read">
    </form>
    -----------------------

    loc.html
    ----------------------
    <div ID="LOCATION">
    <script language="Javascript" src="http://map.geoup.com/geoup"></script>
    <div>
    <script>
    window.opener.myform.mymsg.value = LOCATION.innerText;
    </script>

    ----------------------

IMN logo majestic logo threadwatch logo seochat tools logo