Jump to content

Need help passing parameter to external file


lopes_andre

Recommended Posts

Hi,

 

I have done some JavaScript code for Google Maps API, and the code works, but I need to use the JavaScript in a external file at the same time I need to send a parameter...

 

Let me show some code...

 

Here is the function that I need to send the parameter:

 

// parameter that I need to send
var direction_par;

function initialize(direction_par) { 
      if (GBrowserIsCompatible()) { 
        map = new GMap2(document.getElementById("map_canvas")); 
        map.setUIToDefault(); // adicionar os controlosao mapa ZOOM, 
etc. 


        // Create new geocoding object 
        geocoder = new GClientGeocoder(); 
        // Retrieve location information, pass it to addToMap() 
        geocoder.getLocations(direction_par, addToMap); 


        // Criar o objecto que mostra as direcções 
        gdir = new GDirections(map, document.getElementById 
("directions")); 
        GEvent.addListener(gdir, "load", onGDirectionsLoad); 
        GEvent.addListener(gdir, "error", handleErrors); 
      } 
    } 

 

 

This is where I call the script:

 

script type="text/javascript" 
src="http://localhost/acomp_www/javascript/gm_detalhe.js?direction_par=Rue de la Mad, paris, france">
</script>

 

 

And here is where the function "initialize" is called:

 

<body onload="initialize(direction_par)" onunload="GUnload()">

 

What I'am doing wrong? There is a special way to pass parameters like this one "Rue de la Mad, paris, france", whit spaces?

 

If you can help me out, please reply.

 

 

Best Regards,

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.