Set value element to a other page called by window.open()

前端 未结 2 1886
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 07:00

I\'m struggling to implement this case, I really appreciate your help.

UPDATE :

page1.html



        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-21 07:46

    First of all javascript is case sensetive, and n is missing. so replace getElemetByID with getElementById.

    Second is that the code executes immediately and doesn't wait the page to load. You must wrap your code in window.onload :

    newWindow.onload = function(){
         newWindow.document.getElementById('one').value='xxx';
    }
    

    there's 3 bugs in the update:

    1. function in detailsWindow.onload = function must be declared with detailsWindow.onload = function() to work.
    2. your end script is must be replaced from
    3. you are missing detailsWindow in document.getElementById('one').value = 'test'; it must be detailsWindow.document.getElementById('one').value = 'test';

提交回复
热议问题