1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Javascript Include not work!

Discussion in 'Styling and Customization Questions' started by Tobias19877, Mar 17, 2016.

  1. Tobias19877

    Tobias19877 New Member

    Hello,

    today i had a problem by including an external JavaScript on my Webspace.

    The script is placed under ../js/jquery/myscript.js

    If i include it in footer template, i will see nothing.

    Include Codes tested :

    <xen:require js="alert.js" />

    and

    <script src="../js/jquery/alert.js" />

    Any idea ?
     
    Last edited: Mar 17, 2016
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You need to include the path, like so:
    HTML:
    <xen:require js="js/jquery/myscript.js" />

    Or you can add it to the template directly between script tags, like so:
    HTML:
    <script type="text/javascript">
        JS here
    </script>
     
  3. Tobias19877

    Tobias19877 New Member

    i do this but not working ...
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Both techniques work - I use them in my add-ons.
     
  5. wang

    wang Well-Known Member

    Are you sure that you are adding the code posted above to the templates of the style that you are using and not some other style?
     
  6. Tobias19877

    Tobias19877 New Member

    100% Sure it does NOT work !
     
  7. wang

    wang Well-Known Member

    Can you please post here the code as you are using it?
     
  8. Tobias19877

    Tobias19877 New Member

     
  9. wang

    wang Well-Known Member

    I saw your original post sir. But you were adviced to add the paths correctly. And that is why I said to post the code as you are using it. If you are using the original code, then it will not work. Please see the posts by @Brogan above and correct your code.
     
  10. Tobias19877

    Tobias19877 New Member

    footer template is the path !
     
  11. wang

    wang Well-Known Member

    No, footer template is the name of the template. a.k.a. the location. The path is something else, which has been explained above.
     
  12. Tobias19877

    Tobias19877 New Member

    You need an Example, i give you 3 Examples, 2 in first poost and 1 in quote, what you not understand if the example path is exact that path but the scriptname is not myscript... MAN !!!!!
     
  13. Brogan

    Brogan XenForo Moderator Staff Member

    What does the script do?

    Upload it to this thread (zipped) and I will see if I can get it working.
     
  14. wang

    wang Well-Known Member

    I am sorry sir, but you are not making much sense to me. You are saying that the footer template is the path, when in fact it is not. I was just trying to help. It is no need for yelling and getting irritated. Anyways, I will be unwatching this thread as my help does not seem to be appreciated. Good luck.
     
  15. Tobias19877

    Tobias19877 New Member

    Thanks...

    Added file... Checking Webserver aswell now !
     
  16. katsulynx

    katsulynx Well-Known Member

    I don't see a reason to be so edgy to be honest, we're trying to help you, but you kinda ignore all advices given.

    I'll try to explain you what's going on:
    • As from your first post, it doesn't get clear if your script is named myscript.js or alert.js - that's obviously important to embedd it. Clarify that for yourself in order to get it working
    • To embedd the script insert
      Code:
      <xen:require js=“js/jquery/NAME.js“ />
      into your footer template. Replace NAME with either alert or myscript, depending on how your file is named. Make sure that the coe is exactly as above.
    If it is still not working, one of the following might be the case:
    • Your jQuery-File is broken due to some circumstances, probably the code within it is not working. Tp check if this is the case, add
      Code:
      console.log('Test');
      to the beginning of that file and check the developer console (F12 in most browsers)
    • If the console is empty, you're likely using the wrong path. The path is where your script file is effectively stored (e.g. above it's js/jquery/NAME.js) Check for correct folders, Spelling, capitalization, etc.
     
  17. Tobias19877

    Tobias19877 New Member

    [​IMG]

    [​IMG]

    I now how to include a script, fact is, that this JavaScript not work by including it in Xenforo !

    I was testing the script before upload it ...
     
  18. Tobias19877

    Tobias19877 New Member

    Can be closed, fixxed it, it was an unknown internal error.
     

Share This Page