this is my index.php
<script src="test.js?country=japan" type="text/javascript"></script>
this is my test.js
var url = document.location.href;
url = url.split("?country=");
alert(url[1]);
document.write(url[1]);
when I visit index.php, the page show undefined.. why not showing japan? can help me fix this?
kakinetwork said
this is my index.php<script src="test.js?country=japan" type="text/javascript"></script>this is my test.js
when I visit index.php, the page show undefined.. why not showing japan? can help me fix this?var url = document.location.href; url = url.split("?country="); alert(url[1]); document.write(url[1]);
Would Share Complete Error Your Receive.
In case of Java You should Try Java Error Console . It shows Error On page load.
Since you are getting Error on index.php , It may be some PHP error too
try take a look at http://test.easila.com/
I try to show the word japan.. you can view source
kakinetwork said
try take a look at http://test.easila.com/ I try to show the word japan.. you can view source
Cause You have not provided any parameter to URL
Try this now
http://test.easila.com/index.php?country=japan http://test.easila.com/index.php?country=USA http://test.easila.com/index.php?country=AnyText- Bought between 10 and 49 items
- Contributed a Blog Post
- Contributed a Tutorial to a Tuts+ Site
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Microlancer Beta Tester
- Referred between 100 and 199 users
- Sold between 10 000 and 50 000 dollars
var url = document.location.href;It doesn’t return the script URL , but the page URL . This is how you should do it
var url = document.getElementsByTagName('script')[0].src;
Assuming that script is put at the top.
However, I don’t recommend that way. Create a global variable where you put your parameters
<script>
var param = {
country: japan
};
// when document is ready
$(document).ready(function() {
// load your scripts
});
</script>
thanks omarabid.. you opened my eyes to solve my problem 
