2013年1月14日 星期一

scrolltop chrome firefox某一項無作用


原本這樣用
$('body').stop().delay(800).stop().animate({
scrollTop:0
}, 800);
但常常firefox無作用
於是加入下面html就可
$('body,html').stop().delay(800).stop().animate({
scrollTop:0
}, 800);

2013年1月10日 星期四

wordpress取得目前POST文章的路徑名稱 或是文章 ID


<?php
$pagename = get_query_var('pagename');
if ( !$pagename && $id > 0 ) {
// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
$post = $wp_query->get_queried_object();
 $pagename = $post->post_name;//目前文章 名稱
}
 $postid = get_the_ID();//目前文章ID

?>

2012年10月12日 星期五

flash call js 居然一定要用localhost才能測試


//用flash IDE測試不出來 要用localhost的方式或是丟到網路上 反正就是要成為網路模式 不能本機測試
import flash.external.ExternalInterface;
stop();

ck_mc.addEventListener(MouseEvent.MOUSE_DOWN, overGameMc);
function overGameMc(e:MouseEvent){

//---確認是否能呼叫外部javascript--ok=>true,之後在執行mouseopen()方法;      
 trace('123');
ExternalInterface.call("cool");

}


        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script language="javascript" >

var flashvars = {};
var params = {};
var attributes = {};

params.allowscriptaccess = "always";
attributes.id = "as3_js";
swfobject.embedSWF("trace.swf", "alt", "450", "450", "10.0.0", false, flashvars, params, attributes);

function cool(){
alert("cool");
}


</script>


<div class="as3">
<div id="alt"></div>
</div>



2012年9月20日 星期四

將文字轉數值 parseInt

$("#draggable").css('top');//320px
parseInt($("#draggable").css('top'));//320

2012年9月19日 星期三

用margin:0 auto 置中 要指定該寬度


margin:0 auto;
width:27px;

//用margin:0 auto 置中 要指定該寬度 而不是指定父層

2012年9月11日 星期二

javascript只取數字 用正規表示


var str=$(".area_product").css('left');//出來會是312px
var reg=/[^\d]+/img;
str=str.replace(reg,"");
alert(str);//出來會是312