window.open and $(document).ready

前端 未结 2 841
南笙
南笙 2021-01-15 16:20

I am trying to make a bookmarklet that opens a popup window. Inside this window is a list of CSS classes that once selected, highlights that object on window.opener

2条回答
  •  醉话见心
    2021-01-15 16:36

    Indeed the document.ready never fires.. (i don't know why ..)

    But you can add your script after the html and remove the document.ready since the document is always loaded at that time ..

    function makepopup(){
     var popup = '' +
     'Test' +
     '' +
     '' +
     '
    ' + 'testing popup' + '
    ' + '' + '
    '+ '' + '$(":input").click(function(){ alert($(window.opener.doc'+'ument).find("#test").html()) });' + ''; var testpopup = window.open( '','test','toolbar=1,location=0,status=0,width=500,height=450,scrollbars=1' ); testpopup.document.write(popup); return false; }​

    This works ..

    [UPDATE] BUt the method from Aistina is the correct way to go.

提交回复
热议问题