PHP Simple gallery Javascript Error
Hi everyone,
I have a problem solving a javascript issue that I have with the PHP simple gallery.
http://www.dynamicdrive.com/dynamici...photoalbum.htm.
I modified it a little bit and I almost have what I want.
I need to be able to open the IMG href to a specific script on other site.
Now I tested it and without the gallery script it works.
I added:
Code:
<script type="text/javascript">
function sendcroper(picpath){
window.open("http://www.otherdomain.com?partnerid=1016&imagepath=" + escape(picpath),
"Croper","height=570,width=600,top=50,left=50,scrollbars=no")
}
</script>
Now the function called "sendcroper" I include it in the IMG href:
Code:
<a href="javascript:sendcroper('+imagecompletepath+')" target="'+href_target+'">
'+imagecompletepath+' is the image full path.
This thing doesnt work. it opens a windows with an adddress of:
Code:
javascript:sendcroper(http://www.mydomain.com/pics/c016.jpg)
Now I see that there is target="'+href_target+'" in the href with a var href_target="new" a little up.
When I try to remove target="'+href_target+'" from the href, the link does not open a thing and I'm getting Error:Expected ']' on script error windows.
Can anyone point out what is the problem and why removing the "target" from the href makes this problem?
Here is the full scipt code (after removing "target"). You can also visit http://www.dynamicdrive.com/dynamici...photoalbum.htm for the original code.
Code:
<script src="http://www.mydomain.com/getpics.php" type="text/javascript"></script>
<script type="text/javascript">
function sendcroper(picpath){
window.open("http://www.otherdomain.com/index.aspx?partnerid=1016&imagepath=" + escape(picpath),
"Croper","height=570,width=600,top=50,left=50,scrollbars=no")
}
</script>
<script type="text/javascript">
var dimension="3x3"
var imagepath="http://www.mydomain.com/pics/"
var descriptionprefix=[0]
var gsortorder="desc"
var targetlinkdir=""
function sortbydate(a, b){
return new Date(b[1])-new Date(a[1])
}
galleryarray.sort(sortbydate)
var totalslots=dimension.split("x")[0]*dimension.split("x")[1]
function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="javascript:sendcroper('+imagecompletepath+')">'
tempcontainer+='<img border="0" src="'+imagepath+galleryarray[i][0]+'" title="" />'
tempcontainer+='</a><br />'
return tempcontainer
}
function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}
var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}}
</script>
<div align="center" id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\"> '+i+' </a> ')
document.getElementById("navlink1").className="current"
</script>
a question related to your post
WHat are we trrying to do by putting in quotes as "'+href_target+'"
I want to understand when we can use '+stringvariable+' and when we need the outer quotes?
What exactly '+stringvariable+' would mean?
Meena