This is the link of the page:
localhost/basket/newstext.html?url=http://www.basket-planet.com/ru/news/9246
When the page is loaded, I'm trying to alert the url so I know it's in a variable. But it's not. I found many methods and none work for me. I don't understand why!!! My html page:
<head>
<script src="js/newstext.js"></script>
</head>
<body>
<div data-role="page" id="newstext">
</div>
</body>
js script:
$('#newstext').bind('pageshow', function(event) {
var url = getUrlVars()["url"];
alert (url);
});
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
I'm desperate to get an answer to this...PLEASE HELP OUT!!!
Update: Here is the js script which appends the links and articles on the first page:
var serviceURL = "http://localhost/basket/services/";
var news;
$('#mainNews').bind('pageinit', function(event) {
getNews();
});
function getNews() {
$.getJSON(serviceURL + 'getmainnews.php', function(data) {
$('#fnews li').remove();
mainnews = data.items;
$.each(mainnews, function(index, mnews) {
$('#fnews').append('<li data-icon="false"><a style="white-space:normal;" href="newstext.html?url=http://www.basket-planet.com' + mnews.link + '">' + mnews.article + '</a></li>');
});
$('#fnews').listview('refresh');
});
}