Htaccess show no_found picture if picture is not exist

by in , 0

RewriteEngine On
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*$ /no_picture.png [L]
Let's break it down as to what each line means.
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png)$ [NC]
Check to see if the requested file is of a file extension in the parentheses (). In this case, we're testing to see if the file name ends in either .jpg, .jpeg, .gif or .png
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Check that the file is not there and it's also not a directory.
RewriteRule .*$ /no_picture.png [L]
If a requested resource/file passes all those tests, then it's an image that does not exist. So serve back the image of no_picture.png to the browser. This will keep the filename. If you want to redirect to the no_picture.png filename, change [L] to [R]

auto refresh for every 5 mins in Javascript

by in 0

We can do this function with just html  or just javascript

Refresh document every 300 seconds using HTML Meta tag add this inside the head tag of the page
 <meta http-equiv="refresh" content="300">
Or using Java Script:
            setInterval(function() {
                  window.location.reload();
                }, 300000); 

jQuery javascript regex Replace br tag with \n

by in , , 0

var str = document.getElementById('mydiv').innerHTML;
document.getElementById('mytextarea').innerHTML = str.replace(/<br\s*[\/]?>/gi, "\n");
or using jQuery:
var str = $("#mydiv").html();
var regex = /<br\s*[\/]?>/gi;
$("#mydiv").html(str.replace(regex, "\n"));
edit: added i flag
edit2: you can use /<br[^>]*>/gi wich will match anything between the br and slash if you have for example <br />

Source:

jQuery javascript regex Replace <br> with \n