在我们做网站的时候,经常会遇到这种情况,文章列表li样式是左右class属性来写的,这样就不能用dede的通用列表方式来进行排序,需要让dede自动判断哪个文章是左,哪个文章是右,大多数人到这个时候就会直接改写css,让样式成为通用有规律的属性这样就可以实现正常排序了,但是往往由于css写的比较复杂,或者牵扯到的文件过多,导致我们重新浪费了不少时间,其实ded可以使用eautoindex判断左右不同属性,来达到直接写循环排序。如下:除整求余的应用@me%2==0{dede:arclistrow='4'flag='p'titlelen='20'typeid='59'}<li[field:globalrunphp='yes'name=autoindex]if(@me%2==0){@me="class='floatl'";}else{@me="class='floatr'";}[/field:global]><ahref="[field:arcurl/]"title=""target="_blank"><imgsrc="[field:litpic/]"width="144"height="105"/><p>[field:title/]</p><em></em></a>{/dede:arclist}简化版:<li[field:globalrunphp='yes'name=autoindex]if(@me%2==0){@me="class='fl'";}else{@me="class='fllast'";}[/field:global]>如果是一行三列,可以修改@me%2是数字。
1.表单提交的方式functionmingzi(){varform=document.createElement('form');form.action='http://www.hack001.com';form.target='_blank';form.method='POST';document.body.appendChild(form);form.submit();}这种方式,如果需要传递参数时,需要使用POST方法,默认的GET方法无法传递参数。也就是新页面的url中没有参数部分。另外,Ajax下载文件时也是用form表单来模拟下载。A标签带上:onclick="jr()"即可2.直接将打开窗口操作放在按钮/链接的onclick事件中如:<ahref="javascript:void(0)"onclick="window.open(url)"></a>3.延迟这个打开操作如:setTimeout('window.open(url);',500);//延迟时间不能太短否则也会被拦截4.通过JS打开新窗口会被拦截,换一种实现方式vartempwindow=window.open('_blank');//先打开页面tempwindow.location='http://www.baidu.com';//后更改页面地址转自:https://blog.csdn.net/yypsober/article/details/79487217
$(function(){$("#d-intro").find("img").each(function(){$(this).removeAttr("width").removeAttr("height").removeAttr("style");//if($(this).next("img").size()>0){//使照片之间有缝隙//$(this).after("<br/>");//}$(this).css({"margin":"0","padding":"0","display":"block"});//解决两张图片之间的间隙$(this).css("width","100%").parents().css("text-indent","0em");});})走好选择的路,别选择好走的路转自:https://www.cnblogs.com/weimingxin/p/8963624.html设置好#d-intro对应位置的div,js来控制div中的图片
我们经常遇到火狐兼容,360不兼容,360兼容,ie不兼容,ie兼容,谷歌又不兼容,总之各种不兼容,这个调好了,那个又坏了,针对这一的问题,我们可以针对单一的浏览器单独写样式,这样就可以解决了,比如360兼容,但是火狐不兼容,我们就可以在不改变原css的情况下,针对火狐写个样式,就可以了。也就是说,这段代码任何浏览器都忽略掉它,而火狐看到了就优先渲染它。就是csshack。火狐:@-moz-documenturl-prefix(){这搭是放css语句的处所}Webkit枘核浏览器(chromeandsafari)@mediascreenand(-webkit-min-device-pixel-ratio:0){Selector{property:value;}}上面写法主要是针对Webkit内核的浏览器,如GoogleChrome和Safari浏览器:Opera浏览器:html:first-child>bodySelector{property:value;}或者:@mediaalland(min-width:0){Selector{property:value;}}或者:@mediaalland(-webkit-min-device-pixel-ratio:10000),notalland(-webkit-min-device-pixel-ratio:0){head~bodySelector{property:value;}}IE9浏览器::rootSelector{property:value9;}上面是IE9的写法,具体应用如下::root.demo{color:#ff09;}IE9以及IE9以下版本Selector{property:value9;}background-color:#f1ee18;/*所有识别*/.background-color:#00deff\9;/*IE6、7、8识别*/+background-color:#a200ff;/*IE6、7识别*/_background-color:#1e0bd1;/*IE6识别*/1、Firefox@-moz-documenturl-prefix(){.selector{property:value;}}上面是仅仅被Firefox浏览器识别的写法,具体如:@-moz-documenturl-prefix(){.demo{color:lime;}}支持Firefox的还有几种写法:/*支持所有firefox版本*/#selector[id=selector]{property:value;}或者:@-moz-documenturl-prefix(){.selector{property:value;}}/*支持所有Gecko内核的浏览器(包括Firefox)*/*>.selector{property:value;}2、Webkit枘核浏览器(chromeandsafari)@mediascreenand(-webkit-min-device-pixel-ratio:0){Selector{property:value;}}上面写法主要是针对Webkit内核的浏览器,如GoogleChrome和Safari浏览器:@mediascreenand(-webkit-min-device-pixel-ratio:0){.demo{color:#f36;}}3、Opera浏览器html:first-child>bodySelector{property:value;}或者:@mediaalland(min-width:0){Selector{property:value;}}或者:@mediaalland(-webkit-min-device-pixel-ratio:10000),notalland(-webkit-min-device-pixel-ratio:0){head~bodySelector{property:value;}}上面则是Opera浏览器的Hack写法:@mediaalland(-webkit-min-device-pixel-ratio:10000),notalland(-webkit-min-device-pixel-ratio:0){head~body.demo{background:green;}}4、IE9浏览器:rootSelector{property:value9;}上面是IE9的写法,具体应用如下::root.demo{color:#ff09;}5、IE9以及IE9以下版本Selector{property:value9;}这种写法只有IE9以及IE9以下版本能识别,这里需要注意此处“9”只能是“9”不能是别的,比如说“8”,不然会失去效果的,如:.demo{background:lime9;}6、IE8浏览器Selector{property:value/;}或者:@media�screen{Selector{property:value;}}上面写法只有IE能识别,如:.color{color:#fff/;}或者:@media�screen{.color{color:#fff;}}7、IE8以及IE8以上的版本Selector{property:value�;}这种写法只有IE8以及IE8以上版本支持,如.demo{color:#ff0�;}8、IE7浏览器*+htmlSelector{property:value;}或*:first-child+htmlSelector{property:value;}上面两种是IE7浏览器下才能识别,如:*+html.demo{background:green;}或者:*:first-child+html.demo{background:green;}9、IE7及IE7以下版本浏览器Selector{*property:value;}上面的写法在IE7以及其以下版本都可以识别,如:.demo{*background:red;}10、IE6浏览器Selector{_property/**/:/**/value;}或者:Selector{_property:value;}或者:*htmlSelector{property:value;}具体应用如下:.demo{_width/**/:/**/100px;}或者:.demo{_width:100px;}或者:*html.demo{width:100px;}上面具体介绍了各种版本浏览器下如何识别各种的Hack写法,包括了IE6-9以及现代版本的浏览器写法。综合上面的所述,我们针对不同浏览器的Hack写法主要分为两种从CSS选择器和CSS属性上来区别不同的Hack写法。下面我们分别来看这两种的不同写法:CSS选择器的Hack写法下面我们主要来看CSS选择器和CSS属性选择器在不同浏览器的支持情况。下面先来看CSS选择器支持情况。CSS选择器的Hack写法1、IE6以及IE6以下版本浏览器*html.demo{color:green;}2、仅仅IE7浏览器*:first-child+html.demo{color:green;}3、除IE6之外的所有浏览器(IE7-9,Firefox,Safari,Opera)html>body.demo{color:green;}4、IE8-9,Firefox,Safari,Opearhtml>/**/body.demo{color:green;}5、IE9+:root.demo{color:red;}6、Firefox浏览器@-moz-documenturl-prefix(){.demo{color:red;}}6、Webkit内核浏览器(Safari和GoogleChrome)@mediascreenand(-webkit-min-device-pixel-ratio:0){.demo{color:red;}}7、Opera浏览器@mediaalland(-webkit-min-device-pixel-ratio:10000),notalland(-webkit-min-device-pixel-ratio:0){head~body.demo{color:red;}}8、iPhone/mobilewebkit@mediascreenand(max-device-width:480px){.demo{color:red}}CSS属性Hack写法1、IE6浏览器.demo{_color:red;}2、IE6-7浏览器识别.demo{*color:red;}3、所有浏览器除IE6浏览外.demo{color/**/:red;}4、IE6-9浏览器.demo{color:red9;}5、IE7-8浏览器.demo{color/***/:red9;}上面罗列的都是各种浏览器下的有关于CSS的Hack的写法,基中有针对于现代浏览器Safari,GoogleChrome和Firefox的写法,而且也有针对于我们前端人员最讨厌的IE6-9的各版本浏览器的Hack的写法,而且这些Hack我们又分为CSS选择器的Hack写法和CSS属性的Hack写法。然而具体何种适用,大家可以要据自己的需求来定,下面列出我个人的两种写法:一、经济实惠型定法:这种写法注重单独的CSS的Hack写法。不同的浏览器使用不同的Hack写法,其实也只是以IE的Hack写法比较多(因为我们写Hack也主要是针对IE的浏览器)特别是IE6下的浏览器。单独为各种浏览器写Hack的好处是:针对各种浏览顺的Hack写法省力易记。因为其他的浏览器主要是针对现代浏览器,相对来说是比较少的。针对于这种Hack的使用,我推荐使用下面的方法:.demo{color:red;/*所有现代浏览器*/color:green9;/*所有IE浏览器*/color:lime�;/*IE8-9浏览器*/*color:red;/*IE6-7浏览器*/+color:blue;/*IE7浏览器*/_color:orange;/*IE6浏览器*/}@mediaalland(min-width:0px){color:#000;/*Webkit和Opera浏览器*/}@mediascreenand(-webkit-min-device-pixel-ratio:0){color:#f36;/*Webkit内核浏览器*/}@mediaalland(-wekit-min-device-pixel-ratio:10000),notalland(-webkit-min-device-pixel-ratio:0){head~body.demo{color:#369;}/*Opera*/}@-moz-documenturl-prefix(){.demo{color:#ccc;}/*allfirefox*/}二、完美主义写法这种方法是追求完美主义的写法,主要是配合我们上一节所说的IE条件注释,全部采用选择器Hack的写法。这种写法分两步:1、创建条件样式表,并在HTML中body里添加相应的class类名:<!–[ifIE6]–><<!–[ifIE7]–><!–[ifIE8]–><!–[ifIE9]–><!–[if!IE]–>2、接着创建对应的样式.demo{color:blue;}/*现代浏览器*/.non-ie.demo{color:red;}/*除IE外浏览器*/.ie9.demo{color:yellow;}/*IE9浏览器*/.ie8.demo{color:green;}/*IE8浏览器*/.ie7.demo{color:orange;}/*IE7浏览器*/.ie6.demo{color:lime;}/*IE6浏览器*/@mediaalland(min-width:0px){.demo{color:black;}/*webkitandopera*/}@mediascreenand(-webkit-min-device-pixel-ratio:0){.demo{color:#369;}/*webkit*/}@mediaalland(-webkit-min-device-pixel-ratio:10000),notalland(-webkit-min-device-pixel-ratio:0){head~body.demo{color:#cf6;}/*opera*/}@-moz-documenturl-prefix(){.demo{color:#963;}/*firefox*/}上面就是目前各种浏览器下,相关CSS的Hack的写法,下面我们具体来看一个实例:HTMLMarkuptestcolorCSSCode.demo{color:red;/*所有现代浏览器*/color:green9;/*所有IE浏览器*/color:lime�;/*IE8-9浏览器*/*color:red;/*IE6-7浏览器*/+color:blue;/*IE7浏览器*/_color:orange;/*IE6浏览器*/}:root.demo{color:#9639;}@-moz-documenturl-prefix(){.demo{color:#897;}/*allfirefox*/}@mediascreenand(-webkit-min-device-pixel-ratio:0){.demo{color:#000;}/*webkit*/}@mediaalland(-webkit-min-device-pixel-ratio:10000),notalland(-webkit-min-device-pixel-ratio:0){head~body.demo{color:red;}/*opera*/}资料参考:https://www.cnblogs.com/xujanus/p/5653964.html
<scripttype="text/javascript">//两秒后模拟点击setTimeout(function(){//IEif(document.all){document.getElementById("clickMe").click();}//其它浏览器else{vare=document.createEvent("MouseEvents");e.initEvent("click",true,true);document.getElementById("clickMe").dispatchEvent(e);}},2000);</script><ahref="http://www.hack001.com"id="clickMe"onclick="alert('clicked');">网络营销师</a>
首先看一下调用标签,上一篇是{dede:prenextget=’pre’/}下一篇是{dede:prenextget=’next’/}一、去除上一篇和下一篇的文字,只显示标题。1.修改include/arc.archives.class.php文件,查找”上一篇”关键词,将上一篇去除及可,或者大家也可以改成其它需要的文字,如图所示:织梦修改上一篇下一篇二、限制上一篇和下一篇的标题长度。1.同样是在include/arc.archives.class.php文件里面,加入如下红色代码,设置默认24个字符,中文也就是12个文字。//获取上一篇,下一篇链接functionGetPreNext($gtype=”,$titlelen=28)2.再往下找,插入红色部分!即是用截取后的长度赋予$preRow['title2'],那么原始没截取的就是$preRow['title']$preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow['moresite'],$preRow['siteurl'],$preRow['sitepath']);$preRow['title2']=cn_substr($preRow['title'],$titlelen);$this->PreNext['pre']=”上一篇:<ahref=’$mlink’3.然后在前台模板就可以这样调用了。<listyle=”float:left;”title=”上一篇”>{dede:prenextget=’pre’titlelen=’18′/}</li><listyle=”float:right;”title=”下一篇”>{dede:prenextget=’next’titlelen=’18′/}</li>来自:http://jingyan.baidu.com/article/219f4bf7dddb88de442d380c.html
我们经常使用js跳转来判断手机设备然后进行跳转,不过跳转终究是跳转,而如果使用程序来判断设备进行输出代码,不进行URL跳转岂不是更好,以下是php判断是否为手机,如果为手机就输出指定手机页面,如果不是就输出指定pc页面<?php//判断是否是手机functionisMobile(){$useragent=isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:'';$useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:'';functionCheckSubstrs($substrs,$text){foreach($substrsas$substr)if(false!==strpos($text,$substr)){returntrue;}returnfalse;}$mobile_os_list=array('GoogleWirelessTranscoder','WindowsCE','WindowsCE','Symbian','Android','armv6l','armv5','Mobile','CentOS','mowser','AvantGo','OperaMobi','J2ME/MIDP','Smartphone','Go.Web','Palm','iPAQ');$mobile_token_list=array('Profile/MIDP','Configuration/CLDC-','160×160','176×220','240×240','240×320','320×240','UP.Browser','UP.Link','SymbianOS','PalmOS','PocketPC','SonyEricsson','Nokia','BlackBerry','Vodafone','BenQ','Novarra-Vision','Iris','NetFront','HTC_','Xda_','SAMSUNG-SGH','Wapaka','DoCoMo','iPhone','iPod');$found_mobile=CheckSubstrs($mobile_os_list,$useragent_commentsblock)||CheckSubstrs($mobile_token_list,$useragent);if($found_mobile){returntrue;}else{returnfalse;}}if(isMobile()){include("wap.html");exit();}else{include("index.html");}?>