how to call the .js file function

0

I'm not able to call a javascript function from a file. Ex:

File: javascript within folder raiz/scripts/javascript.js

function responsivo () {
    $('#responsivo').popover({
        //trigger: 'manual',
        placement: 'bottom',
        html: true,
        title: 'O que é um site ou software responsivo?',
        content: $('#Responsivo').html()
    }).popover("show");
};

view that is in the raiz/views/home/Index.cshtml folder

<h3 class="div1Texto2">Sites, Softwares e Lojas Virtuais 100% integrados e <span id="responsivo">responsivos</span></h3>

tag in head tag:

<script src="~/Scripts/javascript.js"></script>

When I rotate the page it does not work, however if I put that function on the page it works normally.

I tried to do this too, but it did not work:

<script type="text/javascript">
    responsivo();
</script>

obs: I was able to call putting onload="responsive ()" in the tag, but if you have many functions like this?

    
asked by anonymous 26.12.2016 / 15:54

1 answer

1

You can use two alternatives, or the relative path , which is relative to the current file. So if this is the location of your index: raiz/views/home/ then the path to your js file would be <script src="../../scripts/javascript.js"></script> . Every ../ is like returning a folder back. The other alternative would be to use the absolute path , which is to place the link where the file is located, it would look like: <script src="http://www.seusite.com/scripts/javascript.js"></script> . I think that's it, I hope I've helped. I did not understand your observation ... comment here

    
26.12.2016 / 16:07