/    Sign up×
Community /Pin to ProfileBookmark

[code]
Hi

Can anybody help me? Ive been playing around with this for a while and I am shaw it is something very obvious but I cant spot it.
Basically I am trying to add a dynamic drive script for popups into my slideshow script.
The problem I think lies in the coding in the links array:

links[2] = “javascript:enlarge(‘pic/mag1.jpg’,event)”;

When I run it through the browser it gives an error message saying object expected.
What am I doing wrong?

<html>
<head>

<style type=”text/css”>

#showimage{
position:absolute;
visibility:hidden;
border: 1px solid gray;
}
#dragbar{
cursor:hand;
cursor: pointer;
background-color: #EFEFEF;
min-width: 100px; /*NS6 style to overcome bug*/

}
#dragbar #closetext{font-weight:bold;
font-size:14px;
font-family:Arial, Helvetica, sans-serif;
margin-right: 1px;
}
</style>

<script language=”javascript” type=”text/javascript”>

var SlideShowSpeed = 3000;
var CrossFadeDuration = 2;
var picture = new Array();
var caption = new Array();
var links = new Array();
var ie=document.all
var ns6=document.getElementById&&!document.all

picture[0] = “pic/bcn2.jpg”;
picture[1] = “pic/bcn1b.jpg”;
picture[2] = “pic/bcn3.jpg”;
picture[3] = “pic/bcn4.jpg”;

caption[0] = “pic/btn1.gif”;
caption[1] = “pic/btn2.gif”;
caption[2] = “pic/btn3.gif”;
caption[3] = “pic/btn4.gif”;

links[0] = “”;
links[1] = “javascript:doImagePopUp1()”;
links[2] = “javascript:enlarge(‘pic/mag1.jpg’,event)”;
links[3] = “http://www.google.com”;

count=0
preload= new Array()
for(i =0 ; i < picture.length; i++){
preload[i] = new Image();
preload[i].src = picture[i];
}

function control(how){
if (how==”F”){count++}
if (how==”B”){count–}

if(count<0){count=picture.length-1}
if(count>picture.length-1){count=0}

if (document.all){
document.images.picturebox.style.filter=”blendTrans(duration=2)”;
document.images.picturebox.style.filter=”blendTrans(duration=CrossFadeDuration)”;
document.images.picturebox.filters.blendTrans.Apply();
}

document.images.picturebox.src = picture[count]
document.images.captionbox.src = caption[count]
document.getElementById(“theLink”).href = links[count];

if (document.all){
document.images.picturebox.filters.blendTrans.Play();
}

}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf(“#”)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf(“?”))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/***********************************************
* Image Thumbnail viewer- ?Dynamic Drive ([url]www.dynamicdrive.com[/url])
* Last updated Sept 26th, 03′. This notice must stay intact for use
* Visit [url]http://www.dynamicdrive.com/[/url] for full source code
***********************************************/

var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
return (document.compatMode && document.compatMode!=”BackCompat” && !window.opera)? document.documentElement : document.body
}

function enlarge(which, e, position, imgwidth, imgheight){
if (ie||ns6){
crossobj=document.getElementById? document.getElementById(“showimage”) : document.all.showimage
if (position==”center”){
pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
if (window.opera && window.innerHeight) //compensate for Opera toolbar
vertpos=pgyoffset+window.innerHeight/2-imgheight/2
vertpos=Math.max(pgyoffset, vertpos)
}
else{
var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
}
crossobj.style.left=horzpos+”px”
crossobj.style.top=vertpos+”px”

crossobj.innerHTML='<div align=”right” id=”dragbar”><span id=”closetext” onClick=”closepreview()”>X&nbsp;</span> </div><img src=”‘+which+'”>’
crossobj.style.visibility=”visible”
return false
}
else //if NOT IE 4+ or NS 6+, simply display image in full browser window
return true
}

function closepreview(){
crossobj.style.visibility=”hidden”
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+”px”
crossobj.style.top=tempy+event.clientY-offsety+”px”
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+”px”
crossobj.style.top=tempy+e.clientY-offsety+”px”
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id==”dragbar”||ns6&&e.target.id==”dragbar”){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function(“dragapproved=false”)

</script>

</head>

<body onLoad=”showHot=true;self.focus(); MM_preloadImages(‘pic/arr1b.gif’,’pic/arr2b.gif’,’pic/bot1.gif’,’pic/bot2.gif’,’pic/bot4.gif’,’pic/bot5.gif’,’pic/bot6.gif’)”>

<div class=”container”>

<div class=”botbox”>

<div id=”showimage”></div>

<table width=”390″ border=”0″ cellspacing=”0″ cellpadding=”0″ align=”right”>
<tr>
<td width=”330″><a href=”#” id=”theLink”><img src=”pic/bcn2.jpg” name=picturebox width=330 height=220 border=0></a></td>
<td width=”60″ valign=”bottom”><a href=”javascript:control(‘F’);” class=”aro2″ ></a><a href=”javascript:control(‘B’);” class=”aro1″></a></td>
</tr>
</table>
</div>
</div>
</body>
</html>[/code]

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@JonaMar 29.2005 — [font=trebuchet ms]Why the [url=http://www.webdeveloper.com/forum/showthread.php?t=61053]duplicate post[/url]?

"Object expected" usually means that you're trying to call a function that doesn't exist. What line is the error occuring on?[/font]
Copy linkTweet thisAlerts:
@jamespatrickauthorMar 29.2005 — Sorry about the duplicate post, I had problems posting it.

The line it gives is this one:

var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX

The page is here www.amalgam-models.co.uk/james/test2.htm
Copy linkTweet thisAlerts:
@JonaMar 29.2005 — [font=trebuchet ms]I don't get any errors on the page you posted in Firefox. It must be an IE problem.

Yep, it is an IE-only problem. The problem seems to be coming from the [i]ietruebody()[/i] function, but I'm not entirely sure. I don't know what "document.compat" is. I'm assuming "compatible" or something similar, but I don't know why you're testing for that. Let me recommend that you make the following change:[/font]

<i>
</i>function ietruebody(){
return (document.documentElement)?document.documentElement:document.body;
}
Copy linkTweet thisAlerts:
@jamespatrickauthorMar 29.2005 — I changed that and put the page back up but still an error message when u click on third foto in slideshow. The popup works I tested it be putting this code:

"enlarge('pic/mag1.jpg',event)" into the html. Its only when I put it into the links it doesnt work.
Copy linkTweet thisAlerts:
@JonaMar 29.2005 — [font=trebuchet ms]The error is "object required," by the way, not "object expected." At least that's the error I got. I don't understand the problem, either, though. I'm short on time at the moment, but I'll try to revisit this thread again.

Wonder if Fang's around? (Hint, hint, Fang. ?)[/font]
Copy linkTweet thisAlerts:
@jamespatrickauthorMar 29.2005 — Sorry my computers in Spanish, bad translation, Thanks for your help.
Copy linkTweet thisAlerts:
@jamespatrickauthorMar 29.2005 — I am at the point of giving up, I cant see where the problem is. I am shaw that its in this line of code "enlarge('pic/mag1.jpg',event)" but I have no Idea whats wrong with it.

Any ideas would b greatly appreciated

thanks
Copy linkTweet thisAlerts:
@FangMar 30.2005 — I didn't get any errors. Is the problem solved?
Copy linkTweet thisAlerts:
@jamespatrickauthorMar 30.2005 — problem solved, I changed "enlarge('pic/mag1.jpg',event)" to

"void enlarge('pic/mag1.jpg','center'300,300)" it was missing some function values.

Thanks anyway.
×

Success!

Help @jamespatrick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...