I am a complete novice at JavaScript but need to use it as part of a PHP page, anyway, i want to click on a button in one of my frames called “toolBar” and open the file data.html in a blank page
For my header i have
<SCRIPT LANGUAGE=“JavaScript”>
function goToURL() {
window.location = “http://shark.cs.stir.ac.uk/~dc065/Dissertation/data.html”;
}
</script>
and my form is:
<form action =“page1.php” method =“post” target=“main”>
<input type=“submit” name=“Submit” value=“View Connected Pages” target=“main” onClick=“goToURL()” target=“_blank”>
Unfortunately the contents of by file keep coming up in my toolBar pane despite my use of targht=“_blank”
Any ideas?
Hi,
The ‘target’ attribute can’t be used on an input. You’ll have to use window.open() in your script:
function goToURL() {
window.open('http://shark.cs.stir.ac.uk/~dc065/Dissertation/data.html');
}
I tried this but now it takes the contents of the frame “toolBar” that the button is in and puts them in my “main” frame.
If the contents of data.html were opening in “main” i would not mind, but would prefer it to open in blank.
Hi,
So, you don’t want the form to be submitted at the same time as the new window is opened? If that’s the case, put the call to goToURL on a separate button, as shown below:
<input type="submit" name="submit" value="View Connected Pages" />
<input type="button" value="open window" onclick="goToURL()" />
When i click the button View connected pages i want a new browser window to open displaying :
‘http://shark.cs.stir.ac.uk/~dc065/Dissertation/data.html’
That is all. But i cant seem to get it to work. I dont want any extra buttons etc. Just simply to click the button to open data.html in a new window.
Hi,
If you just want to open the window, you can remove the form and just have this:
<input type="button" value="View Connected Pages" onclick="goToURL()" />
I have removed the form as you suggested, and put in your code, but now nothing happens at all. no new window, no display of anything
Hi,
Are you sure that the goToURL() function is working properly?
<SCRIPT LANGUAGE=“JavaScript”>
function goToURL() {
window.open = “http://shark.cs.stir.ac.uk/~dc065/Dissertation/data.html”;
}
</script>
It was working to display the contents on the frame with the button before, but now it seems to do nothing
Hi,
The syntax you’re using is not correct. It should look as in my example in post #2.
Didnt notice the brackets, got it now, thanks for all your help.