Javascriptのwindow.onloadとdocument.onloadの違いは何ですか?
document.onload
window.onload
画像、スクリプト、cssなどを含むページ全体が読み込まれると起動します。
<html>
<head>
<title>JavaScript Animation</title>
<script>
<!--
var imgObj = null;
function init() {
imgObj = document.getElementById('myImage');
imgObj.style.position= 'relative';
imgObj.style.left = '0px';
}
function moveRight() {
imgObj.style.left = parseInt(imgObj.style.left) + 10 + 'px';
}
window.onload =init;
//-->
</script>
</head>
<body>
<form>
<img id="myImage" src="/images/html.gif" />
<p>Click button below to move the image to right</p>
<input type="button" value="Click Me" onclick="moveRight();" />
</form>
</body>
</html> -
JavaScriptの関数とメソッドの違いは何ですか?
JavaScriptでも関数とメソッドは同じですが、メソッドはオブジェクトのプロパティである関数です。 以下はJavaScriptの関数の例です- function functionname(param1, param2){ // code } 例 メソッドはオブジェクトに関連付けられた関数です。以下はJavaScriptのメソッドの例です- <html> <head> <script> var e
-
JavaとJavaScriptの違いは何ですか?
Web開発者のJeremyKeithが2009年に述べたように、「JavaはJavaScriptに、ハムはハムスターになります」。そのアナロジーの正確さは議論の余地がありますが、その背後にある精神は確かです。JavaとJavaScriptは、共通の言語ルートを共有しているにもかかわらず、2つの非常に異なるプログラミング言語です。何年にもわたって、それらはもう少し重複するようになりましたが、JavaScriptは、Webサイトをインタラクティブにする主要なフロントエンド言語であり続け、Javaはサーバーサイドおよびアプリケーションプログラミングで引き続き人気があります。開発者を雇ったり、コーディ