After finishing this proof-of-concept, I realized that it only works in Google Chrome, the browser I was using.
I'm not going to try to explain how it works, because it's pretty much noobie scripting.
But basically, in Chrome, it does exactly what it's supposed to and writes copyUrlWindowTe xt, copyUrlWindowEx p, copyUrlWindowCS S and copyUrlWindowSc ript to a new window called copyUrlWindow. But in Firefox and IE, I'm left with just a blank popup.
Here is the code:
Does anyone have any idea why it doesn't work right in IE and Firefox?
Here is a link to the project online: http://developer.jdgre gson.com/projects/current/urlcopy/PopUpParent.htm l
I'm not going to try to explain how it works, because it's pretty much noobie scripting.
But basically, in Chrome, it does exactly what it's supposed to and writes copyUrlWindowTe xt, copyUrlWindowEx p, copyUrlWindowCS S and copyUrlWindowSc ript to a new window called copyUrlWindow. But in Firefox and IE, I'm left with just a blank popup.
Here is the code:
Code:
<html>
<head>
<script type="text/javascript">
function urlWindow()
{
copyUrlWindow=window.open('','','width=300,height=200');
copyUrlWindowScript=document.createElement("SCRIPT");
copyUrlWindowScript.setAttribute("src", "http://developer.jdgregson.com/projects/current/urlcopy/urlScript.js");
copyUrlWindowText=document.createElement("INPUT");
copyUrlWindowText.setAttribute("type", "text");
copyUrlWindowText.setAttribute("id", "copyArea");
copyUrlWindowText.setAttribute("value", "ERROR");
copyUrlWindowText.setAttribute("onclick", "selectText('copyArea')");
copyUrlWindowText.setAttribute("size", "40");
copyUrlWindowExp=document.createElement("P");
copyUrlWindowExp.innerHTML="Click the link in the box to select it. Press Control + C to copy it.";
copyUrlWindowCSS=document.createElement("LINK");
copyUrlWindowCSS.setAttribute("rel", "stylesheet");
copyUrlWindowCSS.setAttribute("href", "http://developer.jdgregson.com/projects/current/urlcopy/popup.css");
copyUrlWindow.focus();
copyUrlWindow.document.head.appendChild(copyUrlWindowScript);
copyUrlWindow.document.head.appendChild(copyUrlWindowCSS);
copyUrlWindow.document.body.appendChild(copyUrlWindowExp);
copyUrlWindow.document.body.appendChild(copyUrlWindowText);
copyUrlWindow.document.body.setAttribute("onfocus", "getUrl();");
}
</script>
</head>
<body>
<input type="button" value="Copy URL" onclick="urlWindow()" />
</body>
</html>
Here is a link to the project online: http://developer.jdgre gson.com/projects/current/urlcopy/PopUpParent.htm l
Comment