目前分類:JavaScript (13)

瀏覽方式: 標題列表 簡短摘要

如果使用比較運算子:「==」、「!=」、「===」、「!==」,需要先使用「date.getTime()」,
例如:

    var d1 = new Date();
    var d2 = new Date(d1);
    var same = d1.getTime() === d2.getTime();
    var notSame = d1.getTime() !== d2.getTime();

建立 Date 物件:

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

如果我已經取得form元素,要如何取得底下的tag呢?

var x = document.getElementById("myForm").elements.length; 

語法:
formObject.elements

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

javascript學習之BOM come from 冬風網+瓢城俱樂部,特此感謝

HTML a href 連結屬性

[架站] 為什麼網站的根目錄最好有 favicon.ico 和 robots.txt 存在?

Robert 發表在 痞客邦 留言(0) 人氣()

 

eval("your script here");

 

參考:Execute JavaScript code stored as a string

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

目前我用的是,frameset 的 onload:

<frameset onload="OnFramesetLoad()">

 

其他寫法:(皆未確認過)

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

原來,要取得frame裡,頁面的元素,還要多一層寫法:

var ele = window.frames['frame_name'].document.getElementById('element_id');

 

參考:How can I get an element from within a frameset frame using JavaScript?

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

總結:

<a href="javascript: handler(); return false;">連結</a>

IE11 會對"return false;" 報錯...;還是先寫下面的好了...:

<a href="javascript:void(0)">連結</a>

 

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

阻止其他定義的default動作。

 

例1:

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

1. 不能寫成 return(false);

2. 在 form tag 要加「return」。

<form action="index.jsp" method="post" onsubmit="return submitTest();">

來源:javascript :onsubmit=return false阻止form表單提交

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

form 表單,在送出前的事件。

  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    return "You have attempted to leave this page.  If you have made any changes to the fields without clicking the Save button, your changes will be lost.  Are you sure you want to exit this page?";
  }

來源:onbeforeunload Demo

 

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

For example, if the name of your form is ‘myform’, the JavaScript code for the submit call is:

document.forms["myform"].submit();

 

But, how to identify a form? Give an id attribute in the form tag

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

語法:

otherWindow.postMessage(message, targetOrigin, [transfer]);

 

otherWindow

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()

廢話不多說,
馬上來看原始碼:

設定:

文章標籤

Robert 發表在 痞客邦 留言(0) 人氣()