Daily Web Snippet

UndeadDragon

Super Moderator
Reaction score
447
The only bad thing with that snippet would be if someone has the same IP as the admin IP (extremely low chances).
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
Detect browsers

2eelau8.png

Code:
switch(navigator.appName)
{
 case "Microsoft Internet Explorer":
  // Do stuff
  break;
 case "Netscape":
  // Do other stuff
  break;
 default:
  // Do stuff for other browsers
}
Syntax Highlighting

34q79y8.png

JavaScript (?)

2vv883t.png

Allows your site to execute JavaScript dependent on the viewers' browser.

n6zucx.png

Add it wherever needed, generally best in head section or external document.

2iqo5yw.png

Chrome seems to be detected as Netscape, and it's not a good idea to rely on this because nothing will happen with non-JavaScript enabled viewers.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
Fake a 404

2eelau8.png

PHP:
<?php
header("HTTP/1.0 404 Not Found");
exit;
?>

34q79y8.png

PHP (?)

2vv883t.png

Fake a 404 page, displays as the default 404 in the browser.

n6zucx.png

Usually used in settings files on direct initialization and the like.

2iqo5yw.png

Can be an excellent security by obscurity addition.
 

ertaboy356b

Old School Gamer
Reaction score
86
Hi, I want to make a request.. I'm a bit dumb in Ajax...

Can you post a snippet in Ajax that can be used in:

1. Updating an element (i.e. div).
2. Getting data from an XML file and using it (childnodes tutorial).

Just a simple framework will do..
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
Updating an element I'll do, I don't do tutorials but I believe w3schools.com has a great one for #2.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
Change Element Content (innerHTML)

2eelau8.png

Code:
<script type="text/javascript">
document.getElementById("YOURID").innerHTML="New content, this can contain HTML"; //Change YOURID to the ID of the desired element.
</script>
Syntax Highlighting

34q79y8.png

JavaScript (?)

2vv883t.png

Changes the content (innerHTML) of any element located by ID to the desired value.

n6zucx.png

Put in <head> section of document.

2iqo5yw.png

This can only change one element at a time.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
Sorry about the lack of snippets, but I've really been caught up in school.

Thanks for your patience.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top