これは私の考えです。私はスタジオのウェブサイトをプログラミングしていますが、単なるページです。たとえば、「Reason why」ページなどのボタンをクリックすると、リダイレクトされずにページの内容が変更されます。基本的に、コードは本当に簡単で、このようなもの:Style.display =デフォルトのdivの「ブロック」はページを開くときに機能しません
function soloprenota() {
document.getElementById("article1").style.display = "block";
document.getElementById("article2").style.display = "none";
document.getElementById("article3").style.display = "none";
}
function soloilnostrosuono() {
document.getElementById("article1").style.display = "none";
document.getElementById("article2").style.display = "block";
document.getElementById("article3").style.display = "none";
}
function soloreasonwhy() {
document.getElementById("article1").style.display = "none";
document.getElementById("article2").style.display = "none";
document.getElementById("article3").style.display = "block";
}
機能を使用すると、ナビゲーションバーに関連するボタンをクリックしたときに呼び出され、すべてのものは、それがどうなるかに動作しています。この問題は、fisrtでページが読み込まれてユーザーが期待するアクションがないことに気づいたときに始まりました。そのため、JavaScriptにこれらのdivの1つ「dafault」を設定する方法はありません。私はいくつかの方法で試してみた
、ほとんどのロジックは、このいずれかである可能性があります
if (jQuery.isDefined(soloprenota) || jQuery.isDefined(soloilnostrosuono) jQuery.isDefined(soloreasonwhy)) {
var examplevar = "examplevaluerlyididntknowwhattomakeitdoesincaseofthis";
} else {
document.getElementById("article1").style.display = "block";
document.getElementById("article2").style.display = "none";
document.getElementById("article3").style.display = "none";
}
決して変更、最初の負荷のページではまだすべてのdivを示しています。 これを解決するにはどうすればよいですか? :/
ページの読み込みで何を達成しようとしていますか?最初のDIVのみを表示する必要がありますか? –