1. Added vanilla js script dom-is-ready.js to

check if DOM content is loaded.
2. Added script source to index.html.
3. Used script in index.js.
pull/92/head
Shantanu Dutta 6 years ago
parent f0f07ee543
commit 890a377ce7

@ -0,0 +1,25 @@
var domIsReady = (function (domIsReady) {
var isBrowserIeOrNot = function () {
return (!document.attachEvent || typeof document.attachEvent === "undefined" ? 'not-ie' : 'ie');
}
domIsReady = function (callback) {
if (callback && typeof callback === 'function') {
if (isBrowserIeOrNot() !== 'ie') {
document.addEventListener("DOMContentLoaded", function () {
return callback();
});
} else {
document.attachEvent("onreadystatechange", function () {
if (document.readyState === "complete") {
return callback();
}
});
}
} else {
console.error('The callback is not a function!');
}
}
return domIsReady;
})(domIsReady || {});

@ -7,6 +7,13 @@
<title>Bin2Dec Converter</title>
</head>
<body>
<form id="form" novalidate>
<div class="form-field">
<input type="text" required>
</div>
<button type="submit">Convert to Decimal</button>
</form>
<script src="dom-is-ready.js"></script>
<script src="index.js"></script>
</body>
</html>

@ -0,0 +1,6 @@
(function (document, window, domIsReady, undefined) {
domIsReady(function () {
console.log('My DOM is ready peeps!');
});
})(document, window, domIsReady);
Loading…
Cancel
Save