I just want to ask a little question so..
I have this code on my main window:
function popupURL(URL) {
var popup = window.open(URL, URL,"status = 1, height = 500, width = 500, resizable = 1");
}
Ok so the user clicks a link like the one below:
<a href="javascript:void(0);" onclick="popupURL('www.google.gr')">Link</a>
And it works, but here’s the thing I want to check when a user clicks a specific element in that page and I know that this can be done with the code below:
<script type="text/javascript">
document.getElementById("submit").onclick = function() {
alert("you clicked submit");
};
</script>
and I want to append that code to the popup window I already have
var tmp = popup.document;
tmp.write(myJsCodeHereFromAbove);
But it doesn’t work because then the document gets rewritten and not appended with my code.
Does anyone know anything about this?
if you write a proxy that sits on your server and fetches that page and then delivers the HTML to your page (you can call an AJAX request to fetch the page’s content), then you can append whatever you want to it and populate it into your window. However, keep in mind that now if there is code in the page that was intended to run on their local domain, it will now be running as though it’s on your domain, so it will suffer from the same security restrictions that you’re feeling now, so, the page you load might break. However, if there is no AJAX driven content on the page you’re loading, then this is a totally viable solution to your problem.