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
Does the $(document).ready
fire if you add the following line before the return false
?
testpopup.document.close();
This is a wild guess though, and I haven't tested this.
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 = '<!DOC'+'TYPE HT'+'ML PUBLIC "-//W3C//DTD HT'+'ML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' +
'<ht'+'ml><he'+'ad><title>Test</title>' +
'<scr'+'ipt type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></scr'+'ipt>' +
'</he'+'ad><bo'+'dy>' +
'<div id="wrap">' +
'testing popup' +
'</div>' +
'<input type="button" value="Click Me" />' +
'</bo'+'dy></ht'+'ml>'+
'<scr'+'ipt type="text/javascript">' +
'$(":input").click(function(){ alert($(window.opener.doc'+'ument).find("#test").html()) });' +
'</scr'+'ipt>';
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.