How to hide image broken Icon using only CSS/HTML?
Viewed 734 times since Wed, Sep 30, 2020
<img src="Error.src" onerror="this.style.display='none'"/>or <img src="Error.src" onerror="this.src='fallback-img.jpg'"/> document.addEventListener("DOMContentLoaded", function(event) { document...
Read More
Hidden image after redirect by check filename
Viewed 558 times since Wed, Sep 30, 2020
$("img.class").load(function() { var noImage = this.src; var xhr; var _orgAjax = jQuery.ajaxSettings.xhr; jQuery.ajaxSettings.xhr = function () { xhr = _orgAjax(); return xhr; }; $.ajax({ type: "GET", url: noImage, success: function(data) { console...
Read More
Get The Current Domain Name With Javascript (Not the path, etc.)
Viewed 524 times since Fri, Oct 2, 2020
If you wish a full domain origin, you can use this: document.location.origin And if you wish to get only the domain, use can you just this: document.location.hostname But you have other options, take a look at the properties in:...
Read More
Strip HTML Tags in JavaScript
Viewed 492 times since Sat, Oct 3, 2020
const originalString = ` <div> <p>Hey that's <span>somthing</span></p> </div> `; const strippedString = originalString.replace(/(<([^>]+)>)/gi, ""); console.log(strippedString);Reference...
Read More
Regex in Javascript to remove links
Viewed 467 times since Sat, Oct 3, 2020
mystr = "check this out <a href='http://www.google.com'>Click me</a>. cool, huh?"; alert(mystr.replace(/<a\b[^>]*>(.*?)<\/a>/i,""));Reference:https://stackoverflow.com/questions/960156/regex-in-javascript...
Read More
Check image width and height before upload with Javascript
Viewed 463 times since Mon, Sep 21, 2020
var _URL = window.URL || window.webkitURL;$("#file").change(function (e) { var file, img; if ((file = this.files[0])) { img = new Image(); var objectUrl = _URL.createObjectURL(file); img.onload = function () { alert(this.width + " " + this.height);...
Read More
XMLHttpRequest.responseURL
Viewed 452 times since Wed, Sep 30, 2020
Example var xhr = new XMLHttpRequest(); xhr.open('GET', 'http://example.com/test', true); xhr.onload = function () { console.log(xhr.responseURL); // http://example.com/test }; xhr.send(null);Reference:https://developer.mozilla...
Read More