ReferenceError: ... is not defined

0
Hello, I'm having a problem with the JavaScript I'm using, I'm going to put the practical example I'm using, in the head of my HTML I have 3 different tag openings. follows:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><scripttype="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 Maps API and the last one is to call Node.js (bundle.js is the Browserify to use require). In HTML I call "insertMar" with a basic onClick

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

But this does not work, I wonder why, since the Google API is still working, does the HTML accept only a script in the head or something?

Thank you very much:)

ps. if I join the two scripts the API stops working

ps2. when I click on the dropdown the browser console shows "ReferenceError: insertMar is not defined"

    
asked by anonymous 22.07.2016 / 21:17

1 answer

1

When you use the src attribute on the <script> tag, the content of the tag is ignored. In other words, having <script src="bundle.js"> and at the same time JavaScript inside the tag is incompatible. Use one 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>
    
22.07.2016 / 21:24