PHP
CSS/HTML
Javascript
Java
Gaming
Biking
Raspberry Pi
Programming
Other...
University

Javascript

Quick Links


Javascript Syntax Highlighter - highlight.js

highlight.js
  <link rel="stylesheet" href="inc/styles/default.css">
  <script src="inc/highlight.pack.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>

Javascript Redirects

<script>window.location.href = "http://google.co.uk";</script>

Using jQuery to Scan a Page & Open All External Links In a New Page

<script>
function validateUrl(textval)   // return true or false.
{
    var urlregex = new RegExp(
          "^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.|http:\/\/|https:\/\/){1}([0-9A-Za-z]+\.)");
    return urlregex.test(textval);
}


$(document).ready(function(){
  // Replace #content with the div you want to search
  $('#content').find('a').each(function() {
    if(validateUrl($(this).attr('href')))
    {
    $(this).attr("target", "_blank");
    }

  });
});
</script>

HTML Links & Ask For Comfirmation

<href="#" onclick="return confirm('Are you sure?')">Confirm Action</a>

Login | Contact Me | Our Friends - npwilson.com | Clockwork Loris | Copyright (©) 2018. Clive Tech.