javascript - Refreshing iframe error -
i using iframe in div block , trying change src through button click following code.
function helloclick(){ var iframe = document.getelementbyid("iframediv"); iframe.src = "hello_world"; iframe.contentdocument.location.reload(true); }
the hello_world file located in same folder file iframe defined. following error message every time click on button.
uncaught typeerror: cannot read property 'location' of undefined
how resolve issue?
try below code snippet
function helloclick(){ var iframe = document.getelementbyid("iframediv"); iframe.src = "hello_world"; iframe.src = iframe.src; }
it should you.
Comments
Post a Comment