javascript - Change HTML page's url & its content -


i trying change content of html page when action on widget taken.

code:

function widget(newurl) {     var server_url = "127.0.0.1:8000";     var oldhtml = document.documentelement.innerhtml;      $.post(server_url + "/convert/",     { input_html: oldhtml, convert: newurl },     function(response) {         var resp = json.stringify(response);         resp = resp.substring(1, resp.length - 1);          var jobj = json.parse(resp);         var win = window.open(newurl,'_self');         document.write(jobj.data);     });         } 

with code, though html content gets changed html page's url doesnot change. can please suggest how can change webpage url content both ?

updated code:

function widget(newurl) {     var server_url = "127.0.0.1:8000";     var oldhtml = document.documentelement.innerhtml;      $.post(server_url + "/convert/",     { input_html: oldhtml, convert: newurl },     function(response) {         var resp = json.stringify(response);         resp = resp.substring(1, resp.length - 1);          var jobj = json.parse(resp);         window.history.pushstate({"html":jobj.data},"", newurl);         document.documentelement.innerhtml = jobj.data;     }); } 

in updated code, url changes content. thanks,

try window.history :

window.history.pushstate({"html":jobj.data,"pagetitle":'hello'},"", newurl);       document.documentelement.innerhtml = jobj.data; 

take @ this answer.

hope helps.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -