I have a link that when clicked on I want a new window opened, and in that window I want to run some javascipt code. This is how I create the link:
$('<a></a>').attr('href', 'javascript:my_func();').attr('target', '_blank')
my_func is run (I set a breakpoint in it and I confirmed that), and there are no errors. But the new window is not created. How can I do this?
EDIT: Trying to implement the solution suggested by @Barmar. Here is my code now:
lwv = load_wafer_viz_on_new_page.toString();
args = '"'+url+'","'+neighbor.data[0]+'","'+date+'"';
lwv += 'load_wafer_viz_on_new_page(' + JSON.stringify(args) + ');'
$('<a></a>').attr('href', 'javascript:var w = window.open();w.innerHTML = "<html><head></head></html>";var script = w.document.createElement("script");script.textContent = lwv;w.document.getElementsByTagName("head")[0].appendChild(script);');
I'm getting a blank page. How do I incorporate this solution into my clickable link?