私はjavascriptが初めてです。以前にサイトにアクセスした場合は Cookie を表示し、それ以外の場合は名前を尋ねる Cookie を作成しようとしました。スクリプトが機能しない理由がわかりません。デバッグを手伝ってください。`
<script type="text/javascript"> //----------- function check() { if(document.cookie.length>0){ return document.cookie } else return "" } //--------- function get(){ var today=new date() today.setDate(today+1) var name=check() if(name=="") {name=prompt("name?","") document.cookie="username="+name+";expires="+today.toUTCString() } else document.write("welcome back"+document.cookie) } </script> </head> <body > <script type="text/javascript"> get(); </script> </body> </html>`<html> this is so frustrating! Passerby already edited the body of this post; your edit must be more substantive to override the current edit.