What this code do? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Other (
https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (
https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: What this code do? (
/showthread.php?tid=619195)
What this code do? -
MerryDeer - 15.10.2016
Код:
<html><head><meta charset="UTF-8"> <script>function check() { var parts = document.domain.split('.'); if(!isNaN(parts[0])) {window.location.href='samp://samp.anyserverip.lt:7777';}ele{ var sndleveldomain = parts.slice(-2).join('.'); sndleveldomain = 'http://' + sndleveldomain; window.location.replace(sndleveldomain);} } </script></head><body onload="check()"></body></html>
Re: What this code do? -
KingHual - 15.10.2016
nothing because ele is not a keyword
Re: What this code do? -
harsimarriar96 - 16.10.2016
It won't work properly because of the syntax error. (Else instead of ele)
It checks if the sitename(Eg.
www.******.com) is number or alphabets.
if its a number/IP, It will launch the samp client application and make the user join the server. Otherwise it will make the user browse the website normally.
Re: What this code do? -
MerryDeer - 16.10.2016
But is there any more mistakes, without that ele?
Re: What this code do? -
Luis- - 16.10.2016
Why not just check it yourself?
Re: What this code do? -
MerryDeer - 16.10.2016
Yes i checked, but maybe there is a little mistake i have to fix or replace function maybe it's outdated or not safe
Re: What this code do? -
ikkentim - 17.10.2016
Step one:
format your code:
Код:
<html>
<head>
<meta charset="UTF-8">
<script>
function check()
{
var parts = document.domain.split('.');
if(!isNaN(parts[0]))
{
window.location.href='samp://samp.anyserverip.lt:7777'; // connects to the the samp server with specified address
}
else // was ele
{ // address is _likely_ an ip
var sndleveldomain = parts.slice(-2).join('.'); // take the last the last two bytes and join them by a dot. e.g. 12.34.23.14 will become 23.14
sndleveldomain = 'http://' + sndleveldomain; // prepend http:// to half the ip
window.location.replace(sndleveldomain); // ??? profit ???
}
}
</script>
</head>
<body onload="check()"></body>
</html>
Guest twice where the error is.
Re: What this code do? -
BurnZ - 18.10.2016
Don't reply to this guy. He makes a topic for every single thing and when people help him, he doesn't even give a thank you.