Referenceerror: ... is not defined

Asked

Viewed 348 times

0

Hello, I’m having a problem with the Javascript I’m using, I’ll put the practical example I’m using, in the head of my HTML I have 3 different tag openings. follow:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">
  function initialize() {
    var mapDiv = document.getElementById('map');
    var myOptions = {
      zoom: 12,
      center: new google.maps.LatLng(41.850033, -87.6500523),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(mapDiv, myOptions);
    addDropDown(map);
  }
  function addDropDown(map) {
    var dropdown = document.getElementById('dropdown-holder');
    map.controls[google.maps.ControlPosition.TOP_RIGHT].push(dropdown);
  }
  google.maps.event.addDomListener(window, 'load', initialize);
</script>

<script src="bundle.js">
var stringAtual = "";
  function insereMarca(){
    stringAtual = stringAtual + ":" + value;
    var funcoes = require('./funcoes')(value);
    alert(funcoes);
  }
</script>

The first two are used for the Google Maps API and the last one is to call Node.js(Bundle.js is Browserify to use require). In HTML I call "inserts" with a basic onClick

<div class="dropdown-item" id="dropd" onclick='insereMarca()'>CLICK ME</div>

However this does not work, I would like to know why, since the Google API is still working, HTML accepts only a script in the head or something like that?

Thanks in advance :)

ps. if I join the two scripts to the API to work

ps2. when I click the dropdown the browser console shows "Referenceerror: inserts Marca is not defined"

1 answer

1

When you use the attribute src in the tag <script> the content of the tag is ignored. That is to say <script src="bundle.js"> and at the same time Javascript inside the tag is incompativel. Uses a tag for each:

<script src="bundle.js"></script>

<script type="text/javascript">
var stringAtual = "";
function insereMarca(){
    stringAtual = stringAtual + ":" + value;
    var funcoes = require('./funcoes')(value);
    alert(funcoes);
}
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.