Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:30:41+00:00 2026-06-02T02:30:41+00:00

<!DOCTYPE html> <html> <head> <meta name=viewport content=initial-scale=1.0, user-scalable=no /> <meta http-equiv=content-type content=text/html; charset=UTF-8 />

  • 0
<!DOCTYPE html>
<html>

    <head>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title>Google Maps JavaScript API v3 Example: Reverse Geocoding</title>
        <link
        href="https://developers.google.com/maps/documentation/javascript/examples/default.css"
        rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript">
            var geocoder;

            var variablejs;

            geocoder = new google.maps.Geocoder();

            var input = "41.021355,-96.020508";
            var latlngStr = input.split(",", 2);
            var lat = parseFloat(latlngStr[0]);
            var lng = parseFloat(latlngStr[1]);
            var latlng = new google.maps.LatLng(lat, lng);

            geocoder.geocode({
                'latLng': latlng
            }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    if (results[0]) {
                        variablejs = results[0].formatted_address; * * //document.write(variablejs); Not working**
                        *
                        //window.location.href = "http://localhost/test2.php?ad="+ variablejs; Working*
                    } else {
                        alert("No results found");
                    }
                } else {
                    alert("Geocoder failed due to: " + status);
                }
            }); * * document.write(variablejs); * * //writes undefined variable (not working)
        </script>
    </head>

    <body></body>

</html>

The section (//document.write(variablejs); Not working), won’t write the variable “variablejs”, but when I use the method (//window.location.href = “http://localhost/test2.php?ad=”+ variablejs; Working), it will write the url and forward the page passing the variable as a parameter. What I want to do is print that variable in the body of the same HTML.
I tried to initialize first the variable then write into the Body but It looks like that section is not accessible like a global variable or something like that. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:30:43+00:00Added an answer on June 2, 2026 at 2:30 am

    Once the document is loaded, you can’t use document.write without overwriting everything. You will need to manipulate the DOM, e.g. document.body.innerText=variablejs;. But I’d recommend

    var d = document.createElement("div");
    d.appendChild(document.createTextNode(variablejs));
    document.body.appendChild(d);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<!DOCTYPE html> <html lang=en> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js type=text/javascript></script> <script type=text/javascript>
I have a problem with running jquery: <!DOCTYPE html> <html> <head> <meta http-equiv=Content-Type content=text/html;
<!DOCTYPE html> <html> <head> <meta name=viewport content=width=device-width, initial-scale=1> <link rel=stylesheet href=http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css /> <script src=http://code.jquery.com/jquery-1.6.4.min.js></script>
this html is here : <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN><html><head><META http-equiv=Content-Type content=text/html;
Here is my code: <!DOCTYPE html> <html> <head> <meta charset=utf-8> <meta name=viewport content=width=device-width, initial-scale=1>
This is my page header: <!DOCTYPE html> <html> <head> <meta name=viewport content=width=device-width, initial-scale=1, minimum-scale=1.0,
<!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Strict//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head> <meta http-equiv=Content-Type content=text/html; charset=UTF-8>
I have the following html code <!DOCTYPE html> <html lang=en> <head> <meta name=viewport content=width=device-width;
This is the code i am using: <!DOCTYPE html> <html lang=en> <head> <meta name=viewport
I have the following code: <!DOCTYPE html> <html> <head> <script src=http://code.jquery.com/jquery-latest.min.js></script> <meta name=viewport content=initial-scale=1.0,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.