PDA

View Full Version : I think I am doing something wrong...


jmacmillan
06-27-2002, 04:09 PM
I have a simple page with a small table in it. It is a test page where I want people to click on a link, and that link will pop open a new smaller window and play a flash document.

I have the coding pretty well, but when I have more than one item on the page, clicking on any link causes the last script listed to execute, instead of the correct one.

Please check the source at

www.imagineering-online.com/downloads.htm

I have checked the syntax several times, and I cannot find anything wrong.

Attached is a txt with some of the source in it.
<p align="center">
<FONT SIZE="2" FACE="helvetica,arial">
You must have the
<a target="new" href="http://www.macromedia.com/software/flashplayer/">Shockwave
Flash</a> plug-in to view these animations.
</FONT>

</p>

<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="77%" id="AutoNumber2">
<tr>
<td width="51%">
<script>


function openpopup(){
var popurl="Files/alqaeda.swf"
winpops=window.open(popurl,"","width=800,height=600,")
}

</script>

<a href="javascript:openpopup()">Al Qaeda Handbook</a></td>
<td width="49%">

<script>


function openpopup(){
var popurl="Files/osama_sissyfight.swf"
winpops=window.open(popurl,"","width=800,height=600,")
}

</script>

<a href="javascript:openpopup()">Osama bin Laden Fight</a></td>
<td width="49%">
</tr>
<tr>
<td width="51%">
<script>


function openpopup(){
var popurl="Files/humor_bin.swf"
winpops=window.open(popurl,"","width=800,height=600,")
}

</script>

<a href="javascript:openpopup()">Osama song starring "GW"</a></td>
<td width="49%">
<script>


function openpopup(){
var popurl="Files/osama_video.swf"
winpops=window.open(popurl,"","width=800,height=600,")
}

</script>

<a href="javascript:openpopup()">Osama bin Laden's "last" video</a></td>
</tr>
<tr>
<td width="51%">
<script>


function openpopup(){
var popurl="Files/finding_bin_laden.swf"
winpops=window.open(popurl,"","width=800,height=600,")
}

</script>

<a href="javascript:openpopup()">Finding Osama bin Laden</a></td>
</td>
<td width="49%"><a href="Files/getosama.exe">Download and &quot;get&quot;
Osama bin Laden</a></td>
</tr>
<tr>
<td width="51%"><a href="Files/Dubya.avi">&quot;Dubya&quot; video</a>&nbsp;&nbsp;&nbsp;
(Note: 5Mb File..Be Patient!)</td>
<td width="49%">&nbsp;</td>
</tr>
</table>
</center>
</div>

<p>&nbsp;</p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber3">
<tr>
<td width="50%"><script>
&nbsp;<a href="javascript:openpopup()">Back Street Boys Parody</a></td>


function openpopup(){
var popurl="Files/bsbgay.swf"
winpops=window.open(popurl,"","width=800,height=600,")
}

</script>
&nbsp;<td width="50%">&nbsp;</td>
</tr>
<tr>
<td width="50%">&nbsp;</td>
<td width="50%">&nbsp;</td>
</tr>
</table>
<p align="center">
&nbsp;</p>
<p align="center">
&nbsp;</p>
<p align="center">&nbsp;</p>

<p align="center"></p>

<p align="center"></p>

</body>

</html>


Thanks for the help

tamienne
06-27-2002, 06:49 PM
well you have all the functions called the same thing. it'll use the last function and that's why you only get the one.
Have one function
<script>
function openpopup(popurl){
winpops=window.open(popurl,"","width=800,height=600,")
}
</script>

and call it in your links
<a href="javascript:openpopup('Files/alqaeda.swf')">Al Qaeda Handbook</a>

Also, remove the space in javascript.

joh6nn
06-27-2002, 06:51 PM
that's because you have the functions all named the same thing, so they're overwriting each other.

what you could do instead, is have just one function, and tell it which page to open, like this:

<script>
function openpopup(popurl){
winpops=window.open(popurl,"","width=800,height=600,")
}
</script>


<a href="javascript:openpopup('Files/alqaeda.swf');">Al Qaeda Handbook</a></td>

tamienne
06-27-2002, 06:57 PM
we must've posted at the same time :)

joh6nn
06-27-2002, 07:17 PM
i think it's also interesting that we have nearly identical answers to the problem.

granted, it's the right answer, but nonetheless.

jmacmillan
06-27-2002, 09:48 PM
Thank you for your expertise. As you can tell, I am a bit of a novice at this.

Is there some sort of general rule to follow when formatting this stuff to prevent this type of conflict?