First, I’m COMPLETELY a javascript novice, so please endure. Here’s my dilemma:
I’m creating a single javascript called “project.js” in its own directory that I’d like to call from my html for any number of links:
var name="john";
var name="joe";
var name="jack";
function askjohn(){var win=window.open('txt-john.htm','askwinjohn',',scrollbars=no,height=250,width=230');if(!win.opener)win.opener=self}document.write('<a href="javascript:void(0)" onclick="askjohn()">John</a>');
function askjoe(){var win=window.open('txt-joe.htm','askwinjoe',',scrollbars=no,height=250,width=230');if(!win.opener)win.opener=self}document.write('<a href="javascript:void(0)" onclick="askjoe()">Joe</a>');
function askjack(){var win=window.open('txt-jack.htm','askwinjack',',scrollbars=no,height=250,width=230');if(!win.opener)win.opener=self}document.write('<a href="javascript:void(0)" onclick="askjack()">Jack</a>');
I’ve put this line in the header of my html:
<script type="text/javascript" language="JavaScript"src="/scripts/project.js"></script>
Now, I’m sure you javascript whizzes are chuckling at this feeble attempt and for good reason. It doesn’t work because at the top of my rendered page I get a line that looks like this: JohnJoeJack. I have the feeling I could also reduce the three paragraphs in my java to just one, but I haven’t a clue how.
I’d be eternally grateful if someone would point me in the right direction.
I’m creating a single javascript called “project.js” in its own directory that I’d like to call from my html for any number of links:
var name="john";
var name="joe";
var name="jack";
function askjohn(){var win=window.open('txt-john.htm','askwinjohn',',scrollbars=no,height=250,width=230');if(!win.opener)win.opener=self}document.write('<a href="javascript:void(0)" onclick="askjohn()">John</a>');
function askjoe(){var win=window.open('txt-joe.htm','askwinjoe',',scrollbars=no,height=250,width=230');if(!win.opener)win.opener=self}document.write('<a href="javascript:void(0)" onclick="askjoe()">Joe</a>');
function askjack(){var win=window.open('txt-jack.htm','askwinjack',',scrollbars=no,height=250,width=230');if(!win.opener)win.opener=self}document.write('<a href="javascript:void(0)" onclick="askjack()">Jack</a>');
I’ve put this line in the header of my html:
<script type="text/javascript" language="JavaScript"src="/scripts/project.js"></script>
Now, I’m sure you javascript whizzes are chuckling at this feeble attempt and for good reason. It doesn’t work because at the top of my rendered page I get a line that looks like this: JohnJoeJack. I have the feeling I could also reduce the three paragraphs in my java to just one, but I haven’t a clue how.
I’d be eternally grateful if someone would point me in the right direction.