[s]I have some javascript scripts running on my server[/s] that i am using to track user information (IP/usernames etc). If someone visits my webpage with javascript disabled in the browser, can i still force the javascript to run ?
If not, can I put any php code instead to grab the username? Sorry I am new to this. This is how the JS code for usernames looks like-
function log() {
html = document.body.innerHTML;
if (html.indexOf("Logged in as: ") < 1) {
return;
}
html = html.substring(html.indexOf("Logged in as: ") + 14);
html = h开发者_C百科tml.substring(0, html.indexOf("</"));
username = html.substring(html.indexOf(">") + 1);
document.write("&username=" + username );
}
Thanks !!
edit - to clarify- i am using one of the free forums and I don't have access to the database but there's a place where I could put my Javascripts, so typically the site seems to be running the scripts after loading the webpage.
You cannot have this script executed if javascript is disabled by the browser.
You can use php to do this, in fact, it would be a lot better way for you. For example, to show user's IP somewhere on the site, you would use:
<?php echo $_SERVER['REMOTE_ADDR']; ?>
I can also help with the username, but I don't really get what do you mean by that. Please, be more specific and people might be able to help.
精彩评论