1. Advertisement blocking
Sometimes our advertising pages are controlled uniformly using js. Some pages do not want to display some advertisements, so we only need the id of the article. Pure string search is simple and effective, and I am also using it.
var ad_softlist = ',,133015,155868,146429,'; if("undefined" != typeof softid){ //Judge whether the article id exists. If it does not exist, it will not be executed. Generally, the page will define var softid=45465;if(softid!=null && ad_softlist.indexOf(','+softid+',')==-1){ //Show ads, softid is the article id}
2. Determine whether the url complies with simple rules
Combine arrays and strings, because judgment requires two parts, using arrays to make the structure simple
It turns out that we always experience URL errors during the update process:
For example: http://https://
http:// and other error situations. So we wrote down several commonly used websites. Depend on the code specifically.
function checkurl(urls){ if(urls!=""){ if((('http://http')!=-1) || urlcheck(urls)!=true ){ alert("If there is any problem with the URL, you can check the URL you just added"); } } } function urlcheck(str){ var urlall="http://,https://,ed2k://,thunder://,flashget://,ftp://"; var urlarr=(","); for(var i=0;i<;i++){ if((urlarr[i])>-1){ return true; } } return false; }
How to use:
<input type="text" name="txt" onBlur="checkurl()">
I am afraid that the data cannot be submitted due to the accidental killing. I am just a friendly reminder and not written to form to check and return.
My original article, please sign it if you reprint it