I have a web page that is supposed to control two different scripts on two different servers in order to begin and end an audio stream. The scripts are started and stopped simply by visiting a URL. The “controller” page looks like this:
Start and Stop the Streaming!
Go Live!
Go Dead!
The code I have is this:
<!DOCTYPE html>
<html lang="en">
<head>
<script language="javascript">
<!--
function goLive(){
parent.targetname.location.href = "http://URL.1server.1";
parent.targetname.location.href = "http://URL.2server.1";
}
function goDead(){
parent.targetname.location.href = "http://URL.1server.2";
parent.targetname.location.href = "http://URL.2server.2";
}
//-->
</script>
</head>
<body>
<h1>Start and Stop the Streaming!</h1>
<br>
<a target="_blank" href="javascript: goLive();">Go LIVE</a>
<br>
<a target="_blank" href="javascript: goDead();">Go Dead</a>
</body></html>
The script fails with this error in the JavaScript console:
Uncaught TypeError: Cannot read property ‘location’ of undefined
localhost:57 goLive localhost:57 (anonymous function) localhost:1
Uncaught TypeError: Cannot read property ‘location’ of undefined
localhost:62 goDead localhost:62
What am I doing wrong? Am I even on the right track?
(window).parent refers to the webpage the current window was opened from.