Say I am opening a webpage (www.facebook.com) by passing the url to window.open() function. My window opens as a new browser since I have used "_blank" in window.open() function.
I want to run my own javascript on the newly opened window. When I researched, found some solution which I have added in my source code as posted below. But unfortunately my javascript is not working on the newly opened window. Could someone help me in this ?
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
var url = document.getElementById("myText").value
var newWindow = window.open(url,'_blank','height=400,width=600,left=10,top=10,scrollbars=yes,menubar=yes,titlebar=yes')
var newScript = newWindow.document.createElement('script');
//console.log(newScript);
newScript.setAttribute('type','text/javascript');
newScript.setAttribute('src','C:/Users/30216/Desktop/jquery_edited_new1.js');
newWindow.document.getElementsByTagName("head")[0].appendChild(newScript);
//console.log(newWindow);
//newWindow.document.head.appendChild(newScript);
}
</script>
</head>
<body>
<table align = "center">
<frame>
<tr>
<td class="url">Enter the URL:</td>
<td>
<input type="text" id="myText"></input>
</td>
</tr>
<tr>
<td>
<button id="browser_open" onclick = "myFunction()">Submit</button>
</td>
</tr>
</frame>
</body>
</html>