JavaScriptを使用して別のWebページにリダイレクトする方法は?
JavaScriptを使用して別のWebページにリダイレクトするには、コードは次のとおりです-
例
<!DOCTYPE html>
<html>
<head>
<h1>Redirect to a Webpage Example</h1>
<button class="redirectBtn">Redirect</button>
<h2>Click the above button to Redirect to another Webpage</h2>
<script>
document .querySelector(".redirectBtn") .addEventListener("click", redirectFunction);
function redirectFunction() {
location.href("https://tutorialspoint.com/");
}
</script>
</body>
</html> 出力
上記のコードは次の出力を生成します-
[リダイレクト]ボタンをクリックすると、新しいサイトにリダイレクトされます-
-
JavaScriptでオートコンプリートを作成するにはどうすればよいですか?
フォームにオートコンプリートを作成するためのコードは次のとおりです- 例 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> * { box-sizing: border-box; } body {  
-
JavaScriptでテキストを切り替える方法は?
JavaScriptでテキストを切り替えるためのコードは、次のとおりです- 例 <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana,