Se eu executar este código, por que a página nunca termina de carregar? Ela sempre mostrará conectando na guia do meu navegador.
É um javascript simples que exibirá uma caixa de alerta e mudará todo o documento para o teste de palavras.
Javascript - testQuery.js
(function (window, undefined) {
var testQuery = function(obj) {
if (!(this instanceof testQuery)) {
return new testQuery(obj);
}
}
testQuery.alertMessage = function () {
alert("alert");
document.write("testing");
};
window.testQuery = testQuery;
}) (window);
HTML - testQuery.html
<html>
<head>
<script src="testQuery.js"></script>
<script>
function onClick() {
testQuery.alertMessage();
}
</script>
</head>
Respostas:
4 para resposta № 1Porque você não fechou o documento.