it does, but the problem is audio player normally works with DOMAIN URL, not path address. but i'm working on a MOD for audio player, need to use a global script (or url) to root, look at the path of this mod:
Root/Player/Song.mp3
Root/Themes/Default/Scipts/Player.js
so that embed script placed into player.js , and i can't write a certain url, cause i don't know the all people url :) , with php we write something like this:
global $siteurl; echo '
src="'$siteurl'/player/Song.mp3
but i need to do this via java script, cause audio player based on JS.
so, i need a global call script to root, or domain name, for eveyone, not only myselft, that mean, when using of this MOD, it load songs from Root, and of course i can't tell the people, edit it manually your self.
You can get the root location very easily, however because IE is a pain in the neck you'll need to check both location.hostname and location.host. Here is a function that will take care of that for you.
Hi there, i'm not similar with js, i want to set url to root (of course without write domain name) is there a way?
look at my e.g:
i want to set address to root folder instead url (domain name)
something like this:
doesn't work? I don't know about the AudioPlayer but normally starting an url with / means it's relative to root.
it does, but the problem is audio player normally works with DOMAIN URL, not path address. but i'm working on a MOD for audio player, need to use a global script (or url) to root, look at the path of this mod:
Root/Player/Song.mp3
Root/Themes/Default/Scipts/Player.js
so that embed script placed into player.js , and i can't write a certain url, cause i don't know the all people url :) , with php we write something like this:
but i need to do this via java script, cause audio player based on JS. so, i need a global call script to root, or domain name, for eveyone, not only myselft, that mean, when using of this MOD, it load songs from Root, and of course i can't tell the people, edit it manually your self.
I didn't use 'Root' in my example. You might wanna try this
window.location.hostnamebut I'm not sure about browser compatibility.Important is how it should placed in link, is it correct?
or must placed between '' or "" , i don't know anyway, it's not working
If that's in JavaScript its more like
{soundFile: window.location.hostname + "/Player/player.mp3"}or something. Can you make a codepen?Sure, here: http://codepen.io/Pedram/pen/rslKG
You can get the root location very easily, however because IE is a pain in the neck you'll need to check both location.hostname and location.host. Here is a function that will take care of that for you.
To use this you would do the following.
Hope this helped.
Thanks for reply, but not working neither, it's weird, when i add this code, player disappeared. try it on my code pen :(
http://codepen.io/Pedram/pen/rslKG