Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

Content changes dynamically using javascript but effects does not remain permanant

  • 2 trả lời
  • 1 gặp vấn đề này
  • 91 lượt xem
  • Trả lời mới nhất được viết bởi mahesh_chavan

more options

When I use javascript to change font/color/size or inner html, it works temporarily only. Changes does not remain permanent. e.g.

<title>Showing Charset</title> <style type="text/css"> .head_class {color:red;font-size:60;font-family:impact;} </style>

<script type="text/JavaScript"> function chngFont() { var el2 = document.getElementById('myfont'); var sfont = el2.value; document.getElementById('head').className = 'head_class'; document.getElementById('head').innerHTML = sfont; // alert(document.seefont.fonttosee.value); } </p><p></script>

Charset

<form name="seefont"> <input type="text" id="myfont" name="fonttosee" size="20" value="arial"> <button onclick="chngFont()">Change font</button> </form>


When I click the button class head_class is applied to heading id "head" and even the text is change to font name entered but just momentarily. If I use alert in the function, the changes remain only till alert is on the screen. The same code works in IE forever ( The changes remain permanent. What are the settings in firefox to make the changes using javascript permanent ?

When I use javascript to change font/color/size or inner html, it works temporarily only. Changes does not remain permanent. e.g. <HTML> <BODY BGCOLOR#FFFF00> <HEAD><TITLE>Showing Charset</TITLE> <STYLE type="text/css"> .head_class {color:red;font-size:60;font-family:impact;} </STYLE> <script type="text/JavaScript"> function chngFont() { var el2 = document.getElementById('myfont'); var sfont = el2.value; document.getElementById('head').className = 'head_class'; document.getElementById('head').innerHTML = sfont; // alert(document.seefont.fonttosee.value); } </script> </head> <body bgcolor=#ffff00> <h1 align=center id="head">Charset</h1> <form name=seefont > <input type="text" id="myfont" name="fonttosee" size=20 value="arial"> <button onclick="chngFont()">Change font</button> </form> </BODY></HTML> When I click the button class head_class is applied to heading id "head" and even the text is change to font name entered but just momentarily. If I use alert in the function, the changes remain only till alert is on the screen. The same code works in IE forever ( The changes remain permanent. What are the settings in firefox to make the changes using javascript permanent ?

Được chỉnh sửa bởi mahesh_chavan vào

Giải pháp được chọn

Your <button> might be submitting the form and causing the page to refresh. Try this to prevent form submission:

<button onclick="chngFont(); return false;">
Đọc câu trả lời này trong ngữ cảnh 👍 1

Tất cả các câu trả lời (2)

more options

Giải pháp được chọn

Your <button> might be submitting the form and causing the page to refresh. Try this to prevent form submission:

<button onclick="chngFont(); return false;">
more options

Thank you so much jscher2000 ! Firefox reloads the page automatically and that was the problem. Now the changes remains permanent

Được chỉnh sửa bởi mahesh_chavan vào