我真的是网络开发的新手。出于某种原因,Javascript 代码(警报)甚至在我的 HTML/CSS 页面加载之前加载。我正在使用示例警报来查看代码会发生什么。理想情况下,它应该在显示警报之前加载整个网页。我在谷歌上查了一会儿,几乎每个人都说最后调用了 Java 脚本文件,这就是我所拥有的。还是不行。
function go() {
alert('hi');
alert('hey there');
}
go();
<header>
<nav>
<h1 class = "second"> RESUMAKER </h1>
<ul>
<li><a href="build.html" target="_blank"><span> Build Your Resume </span></a></li>
<li><a href="createaccount.html" target="_blank"><span> Create Account </span></a></li>
<li><a href="signin.html" target="_blank"><span> Sign in </span></a></li>
<li><a href="resources.html" target="_blank"><span> Resources </span></a></li>
<li><a href="contacts.html" target="_blank"><span> Talk To Us </span></a></li>
</ul>
</nav>
</header>
<h1 class = "third"><strong> What we do? </strong></h1>
<p> 1. We create your resume when you input information such as personal information, educational history, work experience and skills. </p>
<p> 2. The inputted information will be collected, stored, converted and in turn generate arrays of information which can be transformed into a resume.</p>
<p> 3. Then we let you select a predefined resume template all with different fonts and designs, to generate a resume. </p>
<p> 4. After all that is done, we allow you to be able to download generated resume as a PDF, Google or Microsoft Word document. </p>
<div class="footer">
<li><a href="build.html" target="_blank"> Build a resume </a></li>
<li><a href="createaccount.html" target="_blank"> Create Account </a></li>
<li><a href="signin.html" target="_blank"> Sign in </a></li>
<li><a href="resources.html" target="_blank"> Resources </a></li>
<li><a href="contacts.html" target="_blank"> Contact us </a></li>
</div>
<div class="icon-bar">
<a href="#" class="facebook"><i class="fa fa-facebook"></i></a>
<a href="#" class="twitter"><i class="fa fa-twitter"></i></a>
<a href="#" class="google"><i class="fa fa-google"></i></a>
<a href="#" class="linkedin"><i class="fa fa-linkedin"></i></a>
<a href="#" class="youtube"><i class="fa fa-youtube"></i></a>
</div>
最佳答案
发生这种情况是因为您已经在调用 go
函数,正如您在上一条语句 (go();
) 中指定的那样。因此,一旦加载脚本就会发出警报,这可能早于加载 HTML/CSS 页面。
要防止这种情况,请删除该语句,然后从您的 HTML 页面中调用 go
函数。
关于javascript - 出于某种原因,Javascript 甚至在我的 HTML/CSS 页面加载之前加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53111553/