Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

ลบ Hash จาก window.location (URL) ด้วย JavaScript โดยไม่ Refresh หน้า

ใช้ replaceState method บน History API ลบ hash

replaceState() แก้ไข current history entry แทนที่ด้วย state objects, title, และ URL ที่ส่งใน parameters มีประโยชน์ตอน update state object หรือ URL ของ current history entry ตอบสนอง user action

ลบ hash ได้ด้วย

history.replaceState(null, null, ' ');