The src attribute of the frame is read-only. Modifying according to the normal idea (document.frames[faramename].src) will prompt that there is no permission. However, by setting the src attribute of document.getElementById[frameid] or setting the opening target of the pop-up window, we can still achieve the purpose of dynamically modifying the src attribute of the frame. The following is the test code for this test:
Program code <iframe name=frame1 id=frame1 src= width=400 height=400></iframe><br /> <input name=btn2 type=button id=btn2 value=button one (not possible) onclick=document.frames['frame1'].src='http://www.163.com/'; /> <input name=btn3 type=button id=btn3 value=button two (not possible) onclick=document.frames['frame1'].document.location.href='http://www.sohu.com/'; /> <input name=btn type=button id=btn value=button three (can) onclick=document.getElementById('frame1').src='http://www.hao123.com/'; /> <input name=btn4 type=button id=btn4 value=button 4(can) onclick=window.open('http://www.mzwu.com/','frame1'); /> <a href=http://www.CuoXIn.com/ target=frame1>(Yes)</a> |